Skip to content
Advertisement

Convert Sql to linq with groupby

I have view on which I use this request

And it’s running sucessfully

and get me this data

enter image description here

How I need to write it using linq to get same data?

I tried like this

But on new HumpChartDto() {SpendBand = x.SpendBand} I got Cannot resolve symbol 'SpendBand

How I can solve this?

Advertisement

Answer

First, after grouping on SpendBand, you need to access it via Key property. Second, to compute Sum, you can use Sum method.

Note – change the property name accordingly for name I’ve used for SumOfSpendCurrencyJob and SumOfSpendDocumentCount as don’t know the definition of HumpChartDto class.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement