加入3表

扫码查看
本文介绍了加入3表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过LINQ加入3表,我这样做了:

var results = northwind.Products.Join(northwind.Categories,c => c.CategoryID,d => d.CategoryID ,(c,d)=> new {c.ProductID,c.ProductName,c.SupplierID,d.CategoryName})
.Where(q => q.ProductID> 12)
。 (northwind.Suppliers,f => f.SupplierID,g => g.SupplierID,(f,g)
=> new {f.CategoryName,f.ProductName,g.CompanyName,g.ContactName, g.Country});

但查询太长了,谁能告诉我写得更短?

谢谢。


解决方案

I want to join 3 table by LINQ , i did this :

 var results = northwind.Products.Join(northwind.Categories, c => c.CategoryID, d => d.CategoryID, (c, d) => new { c.ProductID, c.ProductName, c.SupplierID, d.CategoryName })
                                            .Where(q => q.ProductID > 12)
                                            .Join(northwind.Suppliers, f => f.SupplierID, g => g.SupplierID, (f, g)
=> new { f.CategoryName, f.ProductName, g.CompanyName, g.ContactName, g.Country });

but the query is too long, who can tell me to write it shorter ?

thank.

         

解决方案


这篇关于加入3表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 04:14
查看更多