在linq中按查询分组 [英] Group by query in linq
本文介绍了在linq中按查询分组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用asp.net mvc 5,实体frmework 5,linq
i有以下表格:
订单:
I am using asp.net mvc 5,entity frmework 5, linq
i have following tables:
order:
1. orderid customerid
1 2
2 3
3 1
orderDetail:
orderDetail:
orderid productname quantity
1 A 10
1 B 15
1 C 20
我想找到数量/客户
即我想报告如下:
I want to find the quantity/customer
i.e i want to make a report like:
Total Quantity per customer:
total total total
Qty Qty Qty
productname customer1 customer2 customer3
1 2 3 33
2 3 2 24
3 4 22 34
对此有何疑问?
和
我如何在报告中实现随机列?
what is the query for this?
and
how i can implement random column in a report?
var query=from p in db.orders
group p.customer by p.orders
into g
select new
{orders=g.order.tolist()}
但这个查询只给了我
订单和客户
but this query is only giving me
orders and customers
推荐答案
看到这个..
更新链接..
http://stackoverflow.com/questions / 9173410 / linq-combined-join-and-group-by [ ^ ]
http://stackoverflow.com/questions/16350516/linq-multi-join-with-group-by-and-get -avarage [ ^ ]
https://www.youtube.com/观看?v = W5L2_wXj6gw [ ^ ] < br $> b $ b
http://stackoverflow.com/questions/7325278/group-by-in-linq [ ^ ]
http://msdn.microsoft.com/en-us/library/bb545971.aspx [ ^ ]
see this..
Updated Link..
http://stackoverflow.com/questions/9173410/linq-combining-join-and-group-by[^]
http://stackoverflow.com/questions/16350516/linq-multi-join-with-group-by-and-get-avarage[^]
https://www.youtube.com/watch?v=W5L2_wXj6gw[^]
http://stackoverflow.com/questions/7325278/group-by-in-linq[^]
http://msdn.microsoft.com/en-us/library/bb545971.aspx[^]
这篇关于在linq中按查询分组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文