C# 如何通过linq在join语句中使用两个条件?
我试图在我的连接中添加两个条件,但我做不到。我使用| |运算符C# 如何通过linq在join语句中使用两个条件?,c#,linq,C#,Linq,我试图在我的连接中添加两个条件,但我做不到。我使用| |运算符 from pay in db.Payments join FlyRpt in db.FlightReportTickets on pay.ObjectIdDepartue equals FlyRpt.DepartureId || FlyRpt.DepartureId equals pay.ObjectIdReturn join prof in db.Profiles on FlyRpt.UserId equals prof
from pay in db.Payments
join FlyRpt in db.FlightReportTickets
on pay.ObjectIdDepartue equals FlyRpt.DepartureId ||
FlyRpt.DepartureId equals pay.ObjectIdReturn
join prof in db.Profiles on FlyRpt.UserId equals prof.UserId
where pay.ReserveType == 1 &&
pay.Transactionsuccess &&
pay.IssueDate >= fromDateTime &&
pay.IssueDate <= toDateTime
select new
{
FlyRpt.FullPrice
};
如果要实施或加入,则需要使用where:
from pay in db.Payments
from FlyRpt in db.FlightReportTickets
where pay.ObjectIdDepartue == FlyRpt.DepartureId
|| FlyRpt.DepartureId == pay.ObjectIdReturn
join prof in db.Profiles on FlyRpt.UserId equals prof.UserId
where pay.ReserveType == 1 &&
pay.Transactionsuccess &&
pay.IssueDate >= fromDateTime &&
pay.IssueDate <= toDateTime
select new
{
FlyRpt.FullPrice,
};
可以使用交叉联接,因为不能在其他联接中使用或:
from pay in db.Payments
from FlyRpt in db.FlightReportTickets
where
pay.ObjectIdDepartue = FlyRpt.DepartureId ||
FlyRpt.DepartureId equals pay.ObjectIdReturn
join prof in db.Profiles
on FlyRpt.UserId equals prof.UserId
where
pay.ReserveType == 1 &&
pay.Transactionsuccess &&
pay.IssueDate >= fromDateTime &&
pay.IssueDate <= toDateTime
select new
{
FlyRpt.FullPrice,
};
或操作……错误消息是什么?无法将运算符| |应用于System.Nullable和System.Nullable类型的操作数