Listfruits = new List { "apple", "banana", "cherry", "pear" }; IQueryable queryableFruits = fruits.AsQueryable(); // LINQ query on IQueryable object var result = queryableFruits.Where(f => f.StartsWith("a")).ToList();
using (var db = new MyDbContext()) { IQueryableIn this example, the AsQueryable method is used to convert a DbSet object representing customers to an IQueryable interface. A LINQ query is then performed to find all customers with the name "John". The result is a list of Customer objects. The System.Linq.Expressions AsQueryable method is part of the System.Core.dll package library in C#.customersQuery = db.Customers.AsQueryable(); var result = customersQuery.Where(c => c.Name == "John").ToList(); }