Reputation: 27996
I have a table with two columns, state and loan like this
State loan
NJ 100
CA 200
NJ 150
CT 300
CT 100
I want to group the loan by state using linq. I have done this but it is not working
var query = from address in context.data_vault.ToList()
group address by address.STATE into addressGroup
select new
{
State = addressGroup.Key,
count = addressGroup.Count()
};
I need to page the results as well.
Please suggest me how to do it
Upvotes: 0
Views: 126
Reputation: 47038
To page the result, just use Skip
and Take
:
int n = 3;
int pageSize = 10;
var pagedQuery = query.Skip(n * pageSize).Take(pageSize);
Upvotes: 1