Tag Archives: Linq

Sum and Count in EF

It bugs me that I need to play around with casting in linq expressions just to make aggregate functions safe. For example: decimal? total = storeDb.Carts .Where(cart => cart.CartId == ShoppingCartId) .Select(c => (decimal ?)c.Count * c.Album.Price) .Sum(); See that … Continue reading

Posted in EF | Tagged , , , | Leave a comment