我有以下SQL query
如何转换为lambda
表达式
select * from ContractItems
where ID in (SELECT distinct contractItemId from ContractPackageItems
where contractPackageId in (SELECT ID from ContractPackage
where ContractID = 680))
从上面的查询我需要知道行是否存在。如果存在行,则返回true。
-TIA
--- ---更新 这是我得到的,但它没有工作
(from contractItem in _entities.ContractItems
where contractItem.ID == (from contractPackageItems in _entities.ContractPackageItems
where contractPackageItems.ContractPackageID == (from contractPackage in _entities.ContractPackages where contractPackage.ContractID == contractId select contractPackage.ID) select contractPackageItems.ContractItemId).Distinct()).Any();
答案 0 :(得分:1)
这不会做你想要的吗?
var results = (from ci in _entities.contractItems
join cpi in _entities.contractPackageItems on ci.ID equals cpi.contractItemId
join cp in _entities.contractPackage on cpi.contractPackageId equals cp.ID
where cp.ContractID = 680
select ci).Any();