Hello guys
does anyone know how to convert this SQL statement to a LINQ to a List?
SELECT TOP(5) COUNT(Tickets.CategoryId), Categories.CategoryName
FROM Tickets
INNER JOIN Categories ON Tickets.CategoryId = Categories.CategoryId
GROUP BY Categories.CategoryName
ORDER BY 1 DESC
The result would be something like this?
public static List<Categories> List()
{
MyEntities db = new MyEntities();
var categories = (from ticket in db.Ticket.Include("Category")
group ticket by ticket.Category.CategoryId into g
orderby g.Count() descending
select g.FirstOrDefault().Category).Take(5).ToList();
return categories;
}