c# - GroupBy in LINQ -
I need a table group by month
The query is made in this way:
var query = from db.bt to db.facts where a.Count_Key == b.Date_key new {A.Month, b.Fact_key}; From this query I'm trying the month group
query = query.GroupBy (x => x.Month); Grid1.DataSource = Query; Grid1.DataBind (); Then I get the following error which says:
Can IGrouping int be converted? In IQueryable
You can:
Var query2 = query.GroupBy (x => x.Month); Grid1.DataSource = query2; Grid1.DataBind (); The problem arises because the var query is inherently assumed by its use. query type IQueryable & lt; SomeAnonymousType & gt; and GroupBy method one IQueryable . These are just two different types.
Comments
Post a Comment