LINQ SELECT OPERATION FUNCTION
// Lambda expression that calculates the price Expression<Func<Nwind.Product, decimal?>> calcPrice = (p) => p.UnitPrice * 1.19m; // Query that selects products var q = from p in db.Products.ToExpandable() where calcPrice.Invoke(p) > 30.0m select new { p.ProductName, OriginalPrice = p.UnitPrice, ShopPrice = calcPrice.Invoke(p) };
Source: tomasp.net
LINQ SELECT OPERATION FUNCTION
// Notice that code for calculating price is repeated var q = from p in db.Products where (p.UnitPrice * 1.19m) > 30.0m select new { p.ProductName, OriginalPrice = p.UnitPrice, ShopPrice = (p.UnitPrice * 1.19m) };
Source: tomasp.net