2
我有一个艺术家表和一个样式表。LinqToSQL分组和计数
艺术家表: ID 名 styleid
样式表 ID 名
一个艺术家有一个风格ID
我试图返回一个风格总结,其中包括风格ID ,风格名称和属于该风格的艺术家数量。
我已经得到了下面的声明,它让我的艺术家的ID和数量,但我不能看到如何也获得样式名称。
return from s in DBContext.Styles
join artist in DBContext.Artists on s.ID equals artist.StyleID
group artist by artist.StyleID into a
select new DTO.StyleSummary
{
ID = a.Key,
NumberOfArtists = a.Count()
};
这是可能的一次往返?