我正在尝试将此 SQL 查询转换为 L2S ..
SELECT TOP 5 vt.*
FROM dbo.ADTEXP_RateDefinitions vt
JOIN
(SELECT vLocationID FROM dbo.Vessel_Table WHERE iOwner=401) V
ON vt.VesselID=V.vLocationID
ORDER BY vt.RateAddedDate DESC
感谢任何帮助或建议谢谢
我正在尝试将此 SQL 查询转换为 L2S ..
SELECT TOP 5 vt.*
FROM dbo.ADTEXP_RateDefinitions vt
JOIN
(SELECT vLocationID FROM dbo.Vessel_Table WHERE iOwner=401) V
ON vt.VesselID=V.vLocationID
ORDER BY vt.RateAddedDate DESC
感谢任何帮助或建议谢谢
试试这个。
var result = (from vt in dbo.ADTEXP_RateDefinitions
join V in (
(from VT1 in dbo.Vessel_Table
where
VT1.iOwner==401
select new {
VT1.vLocationID
})) on vt.VesselID equals V.vLocationID
orderby
vt.RateAddedDate descending
select vt).Take(5)
(from vrt in _db.ADTEXP_RateDefinitions
join vt in _db.Vessel_table
on vrt.VesselId equals vt.locationId
where vt.iOwner == 401
select new
{
VesselId = vrt.VesselId,
Owner = vt.iOwner
}).Take(5)
我认为是这样的:
(from vt in dbo.ADTEXP_RateDefinitions
from v in (from vlt on dbo.Vessel_Table where vlt.iOwner=401 select vlt)
where vt.VesselID = v.vLocationID
orderby vt.RateAddedDate descending
select vt).Take(5);