将内连接..OR转换为LINQ

时间:2013-10-01 02:37:05

标签: linq

我被赋予了一个带有OR条件的SQL内部联接,有人可以帮助转换成linq吗?以下是我转换的LINQ,除了“OR”条件

SQL

SELECT Msg.IntMsg
FROM CRM_MsgTbl Msg
    INNER JOIN CRM_TargetCustTbl TCust ON Msg.intCRM = TCust.intCRM
    INNER JOIN Cust_GroupDetailTbl CustGD ON TCust.intCustGroup = CustGD.intCustGroup
    INNER JOIN Cust_ProfileTbl
    ON  (Cust.bintAccountNo = CustGD.bintAccountNo OR TCust.intCustGroup=0) --How to convert this line to LINQ

LINQ

from Msg in db.CRM_MsgTbl
join TCust in CRM_TargetCustTbl on Msg.intCRM equals TCust.intCRM
join CustGD in Cust_GroupDetailTbl on TCust.intCustGroup equals CustGD.intCustGroup
join Cust in Cust_ProfileTbl on CustGD.bintAccountNo equals Cust.bintAccountNo
select new {
  intMsg = Msg.intMsg
} 

1 个答案:

答案 0 :(得分:0)

这个怎么样?

from Msg in db.CRM_MsgTbl
join TCust in CRM_TargetCustTbl on Msg.intCRM equals TCust.intCRM
join CustGD in Cust_GroupDetailTbl on TCust.intCustGroup equals CustGD.intCustGroup
from Cust in Cust_ProfileTbl
where CustGD.bintAccountNo = Cust.bintAccountNo or TCust.intCustGroup = 0
select Msg.intMsg