LIQN join on 后跟多个条件
sql 版:SELECT [t0].[OrderID], [t0].[CustomerID], [t0].[EmployeeID], [t0].[OrderDate], [t0].[RequiredDate], [t0].[ShippedDate], [t0].[ShipVia], [t0].[Freight], [t0].[ShipName], [t0].[ShipAddress], [t0].[ShipCity], [t0].[ShipRegion], [t0].[ShipPostalCode], [t0].[ShipCountry]
FROM [Orders] AS [t0]
INNER JOIN [Order Details] AS [t1] ON ([t0].[OrderID] = [t1].[OrderID]) AND ([t0].[OrderID] = [t1].[OrderID])
WHERE ([t0].[OrderID] > @p0) AND ([t0].[EmployeeID] = @p1)
LINQ版:from o in Orders join od in OrderDetails on new {oid= o.OrderID,oeid=o.OrderID} equals new {oid=od.OrderID,oeid=od.OrderID }
where o.OrderID>1000 && o.EmployeeID==5
select o
lambda表达式版:
Orders
.Join (
OrderDetails,
o =>
new
{
oid = o.OrderID,
oeid = o.OrderID
},
od =>
new
{
oid = od.OrderID,
oeid = od.OrderID
},
(o, od) =>
new
{
o = o,
od = od
}
)
.Where (temp0 => ((temp0.o.OrderID > 1000) && (temp0.o.EmployeeID == (Int32?)5)))
.Select (temp0 => temp0.o)
.Join (
OrderDetails,
o =>
new
{
oid = o.OrderID,
oeid = o.OrderID
},
od =>
new
{
oid = od.OrderID,
oeid = od.OrderID
},
(o, od) =>
new
{
o = o,
od = od
}
)
.Where (temp0 => ((temp0.o.OrderID > 1000) && (temp0.o.EmployeeID == (Int32?)5)))
.Select (temp0 => temp0.o)