0

I'am learning ASP.Net MVC with SQL Server Database and got stuck in Linq operation query. Can anyone help me to convert this SQL query to Linq, please ?

SELECT ShipName, COUNT(*) AS ShipValues
FROM Invoinces GROUP BY ShipName HAVING COUNT(*) > 30

1 Answers1

0

Try this

var result = Invoinces.GroupBy(x => x.ShipName)
                      .Where(y => y.Count() > 30)
                      .Select(o => new {ShipName = o.ShipName, Count = o.Count()});
Prasad Telkikar
  • 15,207
  • 5
  • 21
  • 44