Hello everyone, I took over an old project that was working great that I updated to .net Core 5
I suddenly have this exception when executing my queries. Despite several searches on the subject, I still cannot find any useful solutions. Thanks in advance to anyone who could guide me on a track
Exception: .FirstOrDefault()' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'
//List
filteredSoldRetailsDtoList = param.sale_product_retails
.Where(x => x.vente.agency.id_enterprise == id_enterprise
&& x.sale.date_sale > startDate && x.sale.date_sale < endDate);
//Best productSale
var BestproductSale= filteredSoldRetailsDtoList
.GroupBy(x => x.product_type_measure.id)
.Select(grp => new
{ number = grp.Key,
sum = grp.Sum(x => x.quantity * x.p_sale),
product = grp.FirstOrDefault().product_type_measure })
.OrderByDescending(x => x.sum).ToList();
...
