I am trying to sum a column and get details member wise
My table data is
id membername cost
1 a 100
2 aa 100
3 a 100
4 aa 0
5 b 100
In Entity Framework I try to sum cost column and get result like this
membername totalcost
a 200
aa 100
b 100
then I am doing this
var result = from o in db.pruchasemasters.Where(d => d.memberid == d.membertable.id && d.entrydate >= thisMonthStart && d.entrydate <= thisMonthEnd)
group o by new { o.membertable.members } into purchasegroup
select new
{
membername = purchasegroup.Key,
total = purchasegroup.Sum(s => s.price)
};
How do I read the results and is my code right or not?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…