IQueryable IGrouping how to work

i returns such type IQueryable< IGrouping<int, Invoice>> List() how can I work with it? as with the general List<Invoice> ?

+7
list generics iqueryable igrouping
source share
1 answer

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

Each grouping has a Key property that allows you to access the group key and IEnumerable<Invoice> , which contains 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(); } 

See 101 Linq Samples for samples and explanations for the various Linq features.

+20
source share

All Articles