db.Products.AsEnumerable();The query executes when you actually enumerate the results, so in that instance AsEnumerable() actually kicks off the query. See LINQ's Deferred Execution feature for more reference. It also makes it possible to do something like this:
var query = db.Products.AsQueryable(); //this does not execute the query if (productNameFilter != null { query = query.Where(p => p.ProductName == productNameFilter); //Still does not execute... } return query.ToArray(); //The ToArray() kicks off the execution, because it takes it out of IQueryable data type.>Hi,
// GET api/Admin > public IEnumerable<Product> GetProducts() > { > return db.Products.AsEnumerable(); > }>
DbSet<Product> Products { get; set; }defined in OrdersContext.cs gets involved here too.