Skip to content
Advertisement

convert sql query included case when then to entity frame work query

I need to do the below query in my project with entity framework. This the query from SQL server

And this is what I tried :

I am not familiar with linq querying …. the above SQL server query gives me

And why I needed that case when in my SQL query => query to select count of records for each year

Advertisement

Answer

You need to reverse GroupBy and Sum in EF. You can also use a condition inside Count directly:

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