【发布时间】:2014-08-06 03:53:22
【问题描述】:
我不知道在 LINQ 的一个连接语句中是否有可能有一个嵌套或 2 个或多个 on c.blah equals b.blah,因为我必须在不影响数据数量的情况下连接一个表
因为如果我将它添加到 where 会减少数据数量并且它充当过滤器
我目前尝试的是添加&& 子句,但它不起作用
var Pos = (from a in db.Position
join b in db.Position_Location
on a.ID equals b.PositionId
join c in db.Customer
on a.CustomerID equals c.ID
join d in db.Customer_Location
on b.LocationId equals d.ID
join f in db.Worker
on userIdNew equals f.userId
join e in db.Worker_Customer_Apply_Shift <----Planning to add new validation here
on a.ID equals e.Client_Customer_PositionID into trial
from newtrial in trial.DefaultIfEmpty()
where
b.LogicalDelete == false
&& a.LogicalDelete == false
&& c.LogicalDelete == false
&& d.LogicalDelete == false
select new
{
a.ID,
Client_CustomerID = c.ID,
LogicalDelete =(newtrial == null ? true : newtrial.LogicalDelete),
}).Distinct().ToList();
在此先感谢 :)
【问题讨论】:
标签: c# mysql sql linq asp.net-mvc-3