eric.bryan
Member
- Joined
- Jun 15, 2014
- Messages
- 8
- Programming Experience
- 3-5
Hello everybody,
I try to get a list from a dataview containing a sum and grouped by some fields.
But the sum doesn't compile.
Do you have and idea ?
Thanks a lot in advance.
Eric
I try to get a list from a dataview containing a sum and grouped by some fields.
C#:
DataView view = _objManager.ACCOUNTS.DefaultView;
// Set RowStateFilter to display the current rows.
view.RowStateFilter = DataViewRowState.CurrentRows;
var res = ((DataTable)view.Table)
.AsEnumerable()
.GroupBy(row => new { ID = row.Field<long?>("ID"), ELEM = row.Field<string>("ELEM") })
.Select(sel => new
{
NAME = sel.First()["NAME"],
ID = sel.First()["ID"],
IBAN = sel.First()["IBAN"],
BIC = sel.First()["BIC"],
INFO = sel.First()["INFO"],
AMOUNT= sel.Sum(s => sel.Sum()["AMOUNT"]) //doesn't work
}).ToList();
But the sum doesn't compile.
Do you have and idea ?
Thanks a lot in advance.
Eric