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
Sarath Kankipati
NA
2
713
How to group by tables in datatable and sum them using ER
Jan 19 2018 2:04 AM
I am a newbie here and I have an issue: I have 5 tables in my database with the same columns and headers, so I want to group by all the tables and I want to sum them.
Suppose if there is a column Amount which is present in all 5 tables, then I want to group by the Amount and I want to sum all the 5 table values using Entity Framework.
This is my code which I'm using to do group by, but I'm unable to do the sum:
private
DataTable ProcessData(DataSet ds)
{
DataTable dt =
new
DataTable();
dt = ds.Tables[0].AsEnumerable()
.GroupBy(r =>
new
{ Col1 = r[
"Name"
], Col2 = r[
"Amt"
], Col3 = r[
"Net"
], Col4 = r[
"Data"
] })
.Select(g => g.OrderBy(r => r[
"max"
]).First())
.CopyToDataTable();
return
dt;
}
Reply
Answers (
1
)
Forced to display to the label after last row selected
how to download the image in asp.net.Image stored in db?