问题描述
数据表名称为dttest.
示例:dttest包含以下数据,
我希望结果如下,即我需要基于group ino ...
的数量和数量列的总和
任何人都可以帮我解决这个问题....
推荐答案
DtTest .AsEnumerable() .GroupBy ( x=> new { BNO = x.Field<int>("BNO"), INO = x.Field<int>("INO"), Desp = x.Field<string>("Desp"), Rate= x.Field<decimal>("Rate") } ) .Select ( x=> new { x.Key.BNO, x.Key.INO, x.Key.Desp, Qty = x.Sum(z=>z.Field<int>("Qty")), x.Key.Rate, Amount = x.Sum(z=>z.Field<decimal>("Amount")) } );
问题描述
i am having a DataTable called dtTest. i just need to select columns from the C# Datatable using Linq concepts
Data Table Name is DtTest.
Example : DtTest Contains the following data's,
i want the result as below, that is i need the SUM of Qty and Amount columns based on group INO...
Can anyone Please help me to solve this....
推荐答案
DtTest .AsEnumerable() .GroupBy ( x=> new { BNO = x.Field<int>("BNO"), INO = x.Field<int>("INO"), Desp = x.Field<string>("Desp"), Rate= x.Field<decimal>("Rate") } ) .Select ( x=> new { x.Key.BNO, x.Key.INO, x.Key.Desp, Qty = x.Sum(z=>z.Field<int>("Qty")), x.Key.Rate, Amount = x.Sum(z=>z.Field<decimal>("Amount")) } );
相关问答
相关标签/搜索