public static void SelectClauseWithAnonymousType() { using var dbCtx = new ExampleDbContext(); var pq = from product in dbCtx.Product where (product.ListPrice > 3000) select new { product.Name, product.ListPrice, product.Size }; foreach (var prod in pq) { Console.WriteLine($"{prod.Name} ({prod.Size}): {prod.ListPrice}"); } }
public static void FetchingMoreThanNeeded() { using var dbCtx = new ExampleDbContext(); var pq = from product in dbCtx.Product where product.ListPrice > 3000 select product; foreach (var prod in pq) { Console.WriteLine($"{prod.Name} ({prod.Size}): {prod.ListPrice}"); } }