0
업데이트 - 환율에 의해 그룹에 내가 원하는그룹과 내가 같은 데이터 세트가 동일한 데이터 세트
Currency amount
USD 1245
INR 564
USD 45645
INR 5676
JPY 5677
을뿐만 아니라 양을 집계하고 동일한 데이터 집합을 업데이트합니다.
var grouped = table.AsEnumerable()
.GroupBy(r => f.Field<String>("Currency"))
.Select(g => new {
Currency = g.Key,
Amount = g.Sum(r => r.Field<int>("amount"))
});
var table2 = table.Clone(); // you can also just use the original table, i just didn't want to merge the data here
foreach(var grp in grouped)
{
var newRow = table2.Rows.Add();
newRow.SetField("Currency") = grp.Currency;
newRow.SetField("amount") = grp.Amount;
}
은 이제 DataTable
에서 데이터베이스를 업데이트 할 DataAdapter
을 사용할 수 있습니다 : 당신은 Linq-To-DataTable
및 Enumerable.GroupBy
을 사용할 수 있습니다
Currency Amount
USD 46890
INR 6240
JPY 5677
내 시나리오에서 Linq를 사용할 수 없기 때문에 Linq 없이는 어떤 방법이 있을까요? –