score:4
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.
Source: stackoverflow.com
Related Query
- When to expect IEnumerable and when to expect IQueryable from a Linq query
- When IQueryable is created from a linq query why is it not a "new" variable?
- How can I check the number of calls to the database in LINQ query when using .NET Core and Code First?
- how to fetch data from database using linq query for relationship 1:N and N:N (between 3 entity) in asp.net mvc EF code first?
- Take the first five elements and the last five elements from an array by one query using LINQ
- Enumerable.Empty<T>().AsQueryable(); This method supports the LINQ to Entities infrastructure and is not intended to be used directly from your code
- Linq query to exclude from a List when a property value of List of different type are equal?
- Performing part of a IQueryable query and deferring the rest to Linq for Objects
- Entity Framework Linq Query to List - Error when using contains: Only primitive types, enumeration types and entity types are supported
- linq query to join two tables and get the count from one table values from the other
- Why is IQueryable twice as fast than IEnumerable when using Linq To Objects
- LINQ query performance issue when fetching data from db in MVC Razor
- LINQ Query Issues when trying to select from empty collection
- How could I use linq when calculating a answer from a symbol and two numbers
- How to return IGrouping from Linq query when grouping
- How to construct IQueryable query using Linq when I just need count without reading all documents in Document-Db database?
- LINQ DynamicLibrary: How to extract count and list from IQueryable
- Retrieve and print data from dynamic sql query with linq
- Linq select strings from list when condition is met and save the index
- LINQ query returns old results when source list is re-initialized
- Linq query to group items and query from the top item in each group
- why the sql query is different on that linq query when run on c# and on vb.net?
- Getting the first result from a LINQ query - why does ElementAt<T>(0) fails when First<T>() succeeds?
- How to get the value of class properties with Linq query and IEnumerable
- Is a full list returned first and then filtered when using linq to sql to filter data from a database or just the filtered list?
- creating Linq to sqlite dbml from DbLinq source code
- LINQ Query To Join Two Tables and Select Most Recent Records from Table B corresponding to Table A
- Pull data from multiple tables in one SQL query using LINQ and Entity Framework (Core)
- Linq sub query when using a repository pattern with EF code first
- C# LINQ : Dynamically create property and values that includes sum of a value from a grouped query
More Query from same tag
- LINQ - Summing numbers stored as string
- LINQ to Entities DateTime is inconsistent
- Linq query from navigation properties
- C# Check null in LINQ query and Transaction Scope giving underlying connection failed to open
- Find sequence in IEnumerable<T> using Linq
- Create custom object from List<T> using .Linq
- LINQ table join with entity Framework
- C# Collection Filtering, where do I begin
- Xmlelement condition to get value of another element using c#
- Using c# GetFiles Length but only count the files with certain amount of chars in filename
- LINQ, select from multi table
- C# OrderBy on nested object Property
- How to compare two lists with multiple objects and set values?
- Connection pool in LINQ to SQL
- Get items by matching predicate method
- Query to filter contacts with given tags while having many to many relation between entities
- filter based on parent attribute
- Problem VB.NET LINQ Group joining
- How to break or Exit from Linq query
- .NET Dynamic Search Function
- Linq Update Query with Multiple Tables
- Linq group by except column
- translating a SQL query into a LINQ to SQL query
- LINQ to check boolean value
- Linq Transpose List
- How do I compose existing Linq Expressions
- How to pre-set a variable in a LINQ expression?
- Linq query returns values instead of setting values (With example) in C#
- Errors say that an expression must be of CollectionType.
- Linq Statement between IList and datatable