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
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
Try this
var result = Invoinces.GroupBy(x => x.ShipName)
.Where(y => y.Count() > 30)
.Select(o => new {ShipName = o.ShipName, Count = o.Count()});