linq to entity GroupBy多个字段
2018-01-10 本文已影响0人
Lulus
var items = _voteRecordRepository.GetAll()
.Where(x => programIds.Contains(x.ProgrammeId))
.GroupBy(x=>new {x.ClientType,x.ProgrammeId})
.Select((group)=>new ProgramVoteRecordSelectItem()
{
ProgramId = group.Key.ProgrammeId,
GetVote=group.Count(),
ClientType=group.Key.ClientType
})
.ToList();
IGrouping<TKey, TElement>资料
https://msdn.microsoft.com/zh-cn/library/windows/apps/bb343251(v=vs.95).aspx