TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Eric Bryan
NA
18
7.6k
Cannot get sum from Dataview list
Jul 31 2020 2:41 PM
Hello everybody,
I try to get a list from a dataview containing a sum and grouped by some fields.
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
Reply
Answers (
6
)
Convert this to linq
How to write Group by in EF using Linq