How to convert SQL Statement with TOP, COUNT and GROUP BY to return an object list with LINQ?

It would look to Linq like a table. You could use the exact query you provided above You may be looking for a Linq only answer, but using a view would be a quick way to get there and you may get a slight boost in performance if you are hitting it very frequently I like to use DB for the things it is good at, and it looks to me like this might just be a good fit If you go with a Linq only solution, you might want to spend a few minutes trying the view and doing timing tests to see if it makes a difference in your app.

It would look to Linq like a table. You could use the exact query you provided above. You may be looking for a Linq only answer, but using a view would be a quick way to get there and you may get a slight boost in performance if you are hitting it very frequently.

I like to use DB for the things it is good at, and it looks to me like this might just be a good fit. If you go with a Linq only solution, you might want to spend a few minutes trying the view and doing timing tests to see if it makes a difference in your app.

My code above works well but you gave me a good idea. It's a nice comment creating a view to simplify things out. Thank you – Junior Mayhé May 8 '10 at 15:38.

Looks like you just need to change the "SELECT" portion of your statement: select new { Count = g.Count(), CategoryName = g.FirstOrDefault().Category. CategoryName }.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions