Simple Linq grouping
how to use group by
in Linq.
SqlServer Sample
select
ActionGroupName,
sum(cast(isnull(solicit_count,0) as int)) as 'SolicitCount'
from
[solicits]
group by
ActionGroupName
my linq version
var groupbyfilter = from v in lstSale
group v by v.ActionGroupName into g
select g.ActionGroupName, sum(g.solicit_count)
i am not gettin开发者_StackOverflow社区g it in proper way.
Try:
var groupbyfilter = from v in lstSale
group v by v.ActionGroupName into g
select new
{
ActionGroupName = g.Key,
Sum = g.Sum(x => x.solicit_count)
};
精彩评论