我想要合併DataTable
s在列表中使用總和或平均值取決於條件。例如:將數據表與條件合併
private DataTable getData(List<DataTable> datas, string[] KeyColumnNames, string valueCol)
{
List<DataTable> dataTables = datas;
//if datas has 3 dataTables in it : dt1, dt2, dt3
// then I want to create another dataTable dtAll which will have the sum of
// valueCol of all three datatables for the row which will be conditioned using
// KeyColumnNames (can be multiple Primary keys)
return dataTable;
}
考慮所有的數據表,因爲它們是從類似的模式,但不同的數據中心的表是完全一樣的,但不同的值。 謝謝。
考慮使用LINQ它有能力聚合以及聯合。 –