我希望通过LINQ实现以下SQL语句,但对于
则无法成功 DECLARE @_Date datetime = '2014-02-25'
SELECT Title,FromDate,ToDate
FROM Positions INNER JOIN
PositionHistories ON Positions.PositionID = PositionHistories.PositionID
and @_Date BETWEEN FromDate and ToDate
where PositionID=58
当我编写以下LINQ查询时
from p in db.Positions
join ph in PositionHistories.where((x => x.FromDate <= _Date && x.ToDate >= _Date)
on p.PositionID equals ph.PositionID
where p.PositionID=58
select new
{
Title,
FromDate,
ToDate
}
我得到以下SQL输出
SELECT Title,FromDate,ToDate
FROM Positions INNER JOIN
PositionHistories ON Positions.PositionID = PositionHistories.PositionID
where PositionID=58 and @_Date BETWEEN FromDate and ToDate
这是不希望的。任何建议