Linq to Entity Join table with multiple OR conditions

后端 未结 3 1188
死守一世寂寞
死守一世寂寞 2020-12-03 17:49

I need to write a Linq-Entity state that can get the below SQL query

SELECT  RR.OrderId
FROM    dbo.TableOne RR
        JOIN dbo.TableTwo  M ON RR.OrderedPro         


        
3条回答
  •  醉话见心
    2020-12-03 18:17

    Multiple Joins :

    var query = (from RR in context.TableOne
                 join M in context.TableTwo on new { oId = RR.OrderedProductId,  sId = RR.SoldProductId} equals new { oId = M.ProductID, sId = M.ProductID }
                 where RR.CustomerID == CustomerID 
                 && statusIds.Any(x => x.Equals(RR.StatusID.Value))
                 select RR.OrderId).ToArray();
    

提交回复
热议问题