我有以下查询:
SELECT S.[FlowOrder], S.[DESCRIPTION], COUNT(I.ID)
FROM WorkFlowStatus AS S
INNER JOIN Item AS I
ON S.ID = I.StatusID
WHERE I.Installation = '1'
GROUP BY S.[Description], S.[FlowOrder]
ORDER BY S.[FlowOrder]
这给了我一个项目的计数,按工作流的外键分组,从我的FK表输出描述性名称。
我已经在后台使用LINQ查询(使用LINQ-to-SQL):
var items = from s in _entities.WorkflowStatus
join i in _entities.Items on s.ID equals i.StatusId
into Statuses
orderby s.FlowOrder
select new {s.Description, ItemCount = Statuses.Count() };
如何将SQL中的where子句放入此LINQ查询中?
答案 0 :(得分:3)
这个怎么样?
var items = from s in _entities.WorkflowStatus
join i in _entities.Items.Where(item=>item. Installation == "1") on s.ID equals i.StatusId
into Statuses
orderby s.FlowOrder
select new {s.Description, ItemCount = Statuses.Count() };