コード例 #1
0
        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}");
            }
        }
コード例 #2
0
        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}");
            }
        }