我有这个LINQ to Entity:
var de = from dm in _context.DamageEvents
where dm.StatusID == statusId
group dm by new { dm.ClientId, dm.Client.ClientName, dm.SiteId, dm.Site.Name, dm.SiteObjectId } into g
select new
{
g.Key.ClientId,
g.Key.ClientName,
g.Key.SiteId,
g.Key.Name,
g.Key.SiteObjectId,
icon = g.Select(i=>i.SiteObject.ObjectModel.ObjectType.Icon).FirstOrDefault()
};
如何将上面的linq从查询语法转换为方法语法。
知道如何实施它?
答案 0 :(得分:0)
这样的事情?
var de = _context.DamageEvents.Where(dm => dm.StatusID == statusId)
.GroupBy(dm => new {dm.ClientId, dm.Client.ClientName, dm.SiteId, dm.Site.Name, dm.SiteObjectId})
.Select(g => new
{
g.Key.ClientId,
g.Key.ClientName,
g.Key.SiteId,
g.Key.Name,
g.Key.SiteObjectId,
icon = g.Select(i => i.SiteObject.ObjectModel.ObjectType.Icon).FirstOrDefault()
});