public async Task<IHttpActionResult> AggregateOnDatabaseAsync()
        {
            using (var context = new AdventureWorksContext())
            {
                // fetch the sum of all order totals, as computed on the database server
                var total = await context.SalesOrderHeaders.SumAsync(soh => soh.TotalDue);

                return Ok(total);
            }
        }
        public async Task<IHttpActionResult> GetRequiredFieldsAsync()
        {
            using (var context = new AdventureWorksContext())
            {
                // project fields as part of the query itself
                var result = await context.Products
                    .Select(p => new ProductInfo {Id = p.ProductId, Name = p.Name})
                    .ToListAsync();

                return Ok(result);
            }
        }
        public async Task<IHttpActionResult> AggregateOnClientAsync()
        {
            using (var context = new AdventureWorksContext())
            {
                // fetch all order totals from the database
                var orderAmounts = await context.SalesOrderHeaders.Select(soh => soh.TotalDue).ToListAsync();

                // sum the order totals here in the controller
                var total = orderAmounts.Sum();

                return Ok(total);
            }
        }
        public async Task<IHttpActionResult> GetAllFieldsAsync()
        {
            using (var context = new AdventureWorksContext())
            {
                // execute the query
                var products = await context.Products.ToListAsync();

                // project fields from the query results
                var result = products.Select(p => new ProductInfo { Id = p.ProductId, Name = p.Name });

                return Ok(result);
            }
        }