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)

posted @ 2015-12-10 11:30  甜菜波波  阅读(2561)  评论(0编辑  收藏  举报