我有这个SQL查询:
select * from jobItem
join taskItem on jobItem.JobItemId = taskItem.JobItemId
join taskWidgetCountItem on taskItem.TaskItemId = taskWidgetCountItem.TaskItemId
join EntityItem on EntityItem.EntityItemId = TaskItem.EntityItemId
left join costCenterItem on taskItem.EntityItemId = costCenterItem.EntityItemId
left join facilityItem on taskItem.FacilityItemId = facilityItem.FacilityItemId
where
TaskWidgetCountItem.WidgetItemId in ( select WidgetItemId from BillingInformationItem)
我想将此查询转换为linq
答案 0 :(得分:0)
与LINQ中的SQL IN
子句等效的是Contains
语句。
IEnumerable<long> validWigetItemIds; // fill from Database or input parameters
var result = DbContext.JobItems
.Where(ji => validWigetItemIds.Contains(ji.WidgetItemId)); // equivalent to IN clause
// other LINQ statements as required by your usecase