求一LINQ语句的写法。
是LINQ TO Object
有个集合persons,定义为List<PersonInfo>,有姓名,性别,部门等信息
现在要列出不同部门的人数
Sql语句很简单,表达方式是
Select Dept,Count(*) from persons Group by Dept
不知道LINQ语句如何写,还请指点(最好是vb.net格式)
------解决方案--------------------form p in persons
group by p.Dept into g
select new
{
dept=g.dept,
g.count()
}
------解决方案--------------------http://www.cnblogs.com/thaught/articles/2083132.html
------解决方案--------------------
------解决方案--------------------VB.NET code
Dim query= Form p in list _
Group p By p.Dept Into g = Group _
Select New With{ .dept=g.Key, .Count=g.count()}
------解决方案--------------------
VB.NET code
Dim query= From p in list _
Group p By p.Dept Into g = Group _
Select New With{ .dept=g.Key, .Count=g.count()}
------解决方案--------------------