New to LINQ but this should be fairly simple.
I'm pulling a recordset of products from the DB:
ReportData= topProductsController.GetWowDetails(CurrentUser.UserId, _companyGroupCode, sector, year, string.Empty, string.Empty, string.Empty);
and from that recordset I'm trying to group the results by the product ID and count:
var productCounts = (from record in wowReportData
group record by record.ProductID into grouping
select new topProduct { Name = grouping.Key, quantity = grouping.Count() });
Here's the class I'm trying to return:
public class topProduct
{
public int quantity { get; set; }
public string Name { get; set; }
public topProduct(string productDesc, int downloadCount)
{
this.Name = productDesc;
this.quantity = downloadCount;
}
}
I'm trying to return a list of these from the function. The current error is that:
topProduct does not contain a constructor that takes 0 parameters