我想在我的linq查询中使用我的实体类属性,它返回一些值。
所以这是我的linq查询;
List<PvmBarChartData> BaseofSegmentIPPGMR = (from si in db.ScoreItem
join s in db.Score on si.ScoreId equals s.Id
join prg in db.ProjectResearchGroup on si.ProjectResearchGroupId equals prg.Id
join rg in db.RgClone on prg.RgCloneId equals rg.Id
join sp in db.SalesPoint on s.SalesPointId equals sp.Id
join c in db.Channel on sp.ChannelId equals c.Id
where (si.ResearchGroupType == ResearchGroupType.ScoreCard && spIds.Contains(s.SalesPointId))
group si by c.Name into g
select new PvmBarChartData
{
GroupName = g.Key,
DataValues = new List<CvmNameValuePair>{ new CvmNameValuePair{
Name = "",
Value = g.Average(x => x.TotalScore)
}
}
})
.ToList();
所以例如我想用我的实体框架模型类'properties'设置Name属性,Name = s.Name,
如何在我的代码上实现此功能?
答案 0 :(得分:0)
一种可以访问s.Name的方法是在g上执行另一个linq查询,因为g现在是分组对象的数据集。
Name = (from gx in g select gx.Name).FirstorDefault();