本文介绍了实体框架T-Sql“具有"相等的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将linq写入包含hading子句的实体查询?
How can I write a linq to entities query that includes a having clause?
例如:
SELECT State.Name, Count(*) FROM State
INNER JOIN StateOwner ON State.StateID = StateOwner.StateID
GROUP BY State.StateID
HAVING Count(*) > 1
推荐答案
是否有理由不只对结果使用where
子句?
Any reason not to just use a where
clause on the result?
var query = from state in states
join stateowner in stateowners
on state.stateid equals stateowner.stateid
group state.Name by state.stateid into grouped
where grouped.Count() > 1
select new { Name = grouped.Key, grouped.Count() };
这篇关于实体框架T-Sql“具有"相等的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!