score:4

Accepted answer

In general, LINQ extension methods on IQueryable (defined in Queryable) return IQueryables, and the ones on IEnumerable (defined in Enumerable) return IEnumerables. In this particular case, Configurations is a collection (IEnumerable) on the first returned Location object. Therefore the .Select call returns an IEnumerable.

EDIT: To make it all execute remotely, you could try this:

Context.Locations.Where(l => l.Name == "SomeName").Configurations

Assuming that your filter on Locations is only going to return one row, you should get the same result. Of course it will be an IQueryable, but that shouldn't make a difference. If you need to materialize it, you can do something like:

Context.Locations.Where(l => l.Name == "SomeName").Configurations.ToList()

score:1

Basically, IQueryable allows for remote data sources (like SQL Server). It will work against the database, if possible. IEnumerable works with in-memory collections.

So, if you are querying a SQL Server database, you will get an IQueryable. Otherwise it'll be an IEnumerable.

This article may further help you.


Related Query