文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>entity framework进行一对多的联合查询

entity framework进行一对多的联合查询

时间:2010-10-28  来源:xuesky

 1 using (AdventureWorksEntities AWEntities = new AdventureWorksEntities())
2 {
3 ObjectQuery<SalesOrderHeader> orders = AWEntities.SalesOrderHeader;
4 ObjectQuery<SalesOrderDetail> details = AWEntities.SalesOrderDetail;
5
6 var query =
7 from order in orders
8 join detail in details
9 on order.SalesOrderID
10 equals detail.SalesOrderID into orderGroup
11 select new
12 {
13 CustomerID = order.SalesOrderID,
14 OrderCount = orderGroup.Count()
15 };
16
17 foreach (var order in query)
18 {
19 Console.WriteLine("CustomerID: {0} Orders Count: {1}",
20 order.CustomerID,
21 order.OrderCount);
22 }
23 }
24
25

 

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载