问题描述
我想通过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表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!