I had this question turn up during a job interview, and I thought it might be a good idea to write an article for this.
IQueryable<Rental> rentals1 = from r in db.Rentals where r.City == "Tampa"
IEnumerable<Rental> rentals = from r in db.Rentals where r.City == "Tampa"
The difference here is that IQueryable
Let’s move on to the next part and assume we want to filter the above results by setting a maximum price of 1000 dollars.
var filteredRentals1 = rentals.Where(r => r.Price < 1000);
var filteredRentals2 = rentals.Where(r => r.Price < 1000);
Now here is where it gets even more clear. In the variable ‘filteredRentals1’ which uses the IQueryable
It now becomes abundantly clear that using IQueryable