MVC中linq分组问题,我想按照姓名分组
public ActionResult Item()
{
var linq = from c in db.Companys
from d in db.Departments
from b in db.Brokers
where c.CompanyId == d.CompanyId
where d.DeptId == b.DeptId
orderby c.CompanyName
select new vmodel
{
ComId = c.CompanyId, //公司ID
ComName = c.CompanyName, //公司名称
DeptComId = d.CompanyId, //部门所属的公司ID
DeptId = d.DeptId, //部门ID
DeptName = d.IH_Name, //部门名称
BrokerDeptId = b.DeptId, //经纪人所属部门ID
BrokerId = b.UserId, //经纪人ID
BrokerName = b.RealName
}.ComName.GroupBy(c.CompanyId);
return View(linq);
}
我现在数据是这样的
2 安居房产 2 1 汇沅开元分店 1 1 陈先生 Edit | Details | Delete
2 安居房产 2 1 汇沅开元分店 1 15 郑惠华 Edit | Details | Delete
2 安居房产 2 1 汇沅开元分店 1 16 毕文彬 Edit | Details | Delete
2 安居房产 2 1 汇沅开元分店 1 17 颜晓辉 Edit | Details | Delete