使用 lambda 表达式连接 2 和 3 表的简单示例 [英] Simple Examples of joining 2 and 3 table using lambda expression
本文介绍了使用 lambda 表达式连接 2 和 3 表的简单示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
谁能告诉我两个使用 LAMBDA EXPRESSION(
例如使用 Northwind 表(Orders、CustomerID、EmployeeID)?
Can anyone show me two simple examples of joining 2 and 3 tables using LAMBDA EXPRESSION(
for example using Northwind tables (Orders,CustomerID,EmployeeID)?
推荐答案
加入3个表的代码是:
var list = dc.Orders.
Join(dc.Order_Details,
o => o.OrderID, od => od.OrderID,
(o, od) => new
{
OrderID = o.OrderID,
OrderDate = o.OrderDate,
ShipName = o.ShipName,
Quantity = od.Quantity,
UnitPrice = od.UnitPrice,
ProductID = od.ProductID
}).Join(dc.Products,
a => a.ProductID, p => p.ProductID,
(a, p) => new
{
OrderID = a.OrderID,
OrderDate = a.OrderDate,
ShipName = a.ShipName,
Quantity = a.Quantity,
UnitPrice = a.UnitPrice,
ProductName = p.ProductName
});
谢谢
这篇关于使用 lambda 表达式连接 2 和 3 表的简单示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文