我想知道是否有可能从Linq表达式中获得List<IGrouping<string, IGrouping<string, T>>>
。我想做的是按流派和艺术家排列歌曲,但是我可以通过每种流派和每种流派迭代的格式,为每张专辑进行迭代。如果可能的话该怎么办?还是有更好的方法来实现我想要实现的目标?与LinQ嵌套IGrouping
这是我的歌类
public class Song
{
[StringLength(100)]
public string Album { get; set; }
public int Id { get; set; }
[StringLength(100)]
public string Title { get; set; }
[StringLength(100)]
public string Genre { get; set; }
[StringLength(255)]
public string Comment { get; set; }
[StringLength(4)]
public string Year { get; set; }
[StringLength(100)]
public string Author { get; set; }
public int Length { get; set; }
[StringLength(255)]
public string Photo { get; set; }
[StringLength(255)]
public string FileName { get; set; }
public string Extension { get; set; }
}
而且此查询我在这里
var songs = db.Songs.GroupBy(s => s.Genre).ToList();
给了我一个List<IGrouping<string, Song>>
,但我要的是进一步按艺术家。
[Linq Getting Customers group by date,then by type]可能重复(http://stackoverflow.com/questions/19703034/linq-getting-customers-group-by-date-and-then-by-他们的类型) – Clint