Speed Up Your LINQ Statements with “Let”
This post being last post of the year 2011. Have a great going for year 2012! Wish all of you a happy prosperous new year
Using Linq Let keyword :
Old way :
var cheapCategories = from cat in Categories
where cat.Products.Average(p => p.Price) p.Price) };
New Way :
var cheapCategories = from cat in Categories
let AvgPrice = cat.Products.Average(p => p.Price)
where AvgPrice < 100
select new { cat.Name, AvgPrice };
Its code is pretty straight forward to the point!
Advertisement