Returning IEnumerable<T> vs. IQueryable<T>
Asked 07 September, 2021
Viewed 1.3K times
  • 62
Votes

What is the difference between returning IQueryable<T> vs. IEnumerable<T>, when should one be preferred over the other?

IQueryable<Customer> custs = from c in db.Customers
where c.City == "<City>"
select c;

IEnumerable<Customer> custs = from c in db.Customers
where c.City == "<City>"
select c;

Will both be deferred execution and when should one be preferred over the other?

14 Answer