How to convert SQL Statement with TOP, COUNT and GROUP BY to return an object list with LINQ
- by Junior Mayhé
Hello guys
does anyone know how to convert this SQL statement to a LINQ to a List?
SELECT TOP(5) COUNT(CategoryId), CategoryName
FROM Tickets
GROUP BY CategoryName
The result would be something like
public static List<Categories> List()
{
MyEntities db = new MyEntities();
/* here it should return a list o Category type */;
return db.Category.GroupBy(...).OrderBy(...);
}