关于linq查询
如何用linq多表连接查询,且实现行转列的效果,求代码!!!
------解决方案--------------------http://topic.csdn.net/u/20110106/11/f9078b48-5c44-4bfa-8c61-e28ae056c0b2.html
------解决方案--------------------LINQ 行转列
------解决方案--------------------var rs = from tab1 in 表1
from tab2 in 表2
where
条件
行转列
/// <summary>
/// 将DataTable行转列
/// </summary>
/// <param name="table"></param>
/// <returns></returns>
public static DataTable DataTableFormat(DataTable table)
{
DataTable Formatdt = new DataTable();
Formatdt.Columns.Add(new DataColumn());
for (int i = 0; i < table.Rows.Count; i++)
{
Formatdt.Columns.Add(new DataColumn());
}
for (int i = 0; i < table.Columns.Count; i++)
{
DataRow row = Formatdt.NewRow();
row[0] = table.Columns[i].ColumnName;
for (int j = 1; j <= table.Rows.Count; j++)
{
row[j] = table.Rows[j - 1][i];
}
Formatdt.Rows.Add(row);
}
return Formatdt;
}