开发者

IQueryable IGrouping how to work

开发者 https://www.devze.com 2022-12-23 05:00 出处:网络
i return such type IQueryable< IGrouping<int, Invoice>> List() how can i work with it? like with generic 开发者_JAVA技巧List<Invoice> ?No, you have a IGrouping<int, Invoice> as

i return such type IQueryable< IGrouping<int, Invoice>> List() how can i work with it? like with generic 开发者_JAVA技巧List<Invoice> ?


No, you have a IGrouping<int, Invoice> as your list member.

Each grouping has a Key property allowing you access to the key of the group and an IEnumerable<Invoice> containing the grouped Invoices.

So to access it ...

IQueryable< IGrouping<int, Invoice>> List() groupedIvoices = //... get your grouping
foreach (var group in groupedIvoices ) {
    var key = group.Key;
    var invoicesInGroup = group.ToList();
}

Look at 101 Linq Samples for samples and explanations for the different Linq functions.

0

精彩评论

暂无评论...
验证码 换一张
取 消