IEnumerable<T>. It may not have methods of its own, but it aggregates these other three interfaces as one, so you don't have to deal with them separately.
IQueryable<T> is needed because it defines a contract that is required for a LINQ provider. Many of the extension methods available on
IQueryable<T> are designed to accept expressions rather than delegates.
This is important as a LINQ provider will need to analyze the expression tree rather than invoke a delegate.
IQueryable<T> also extends
IQueryable. Basically it's an
IQueryable which can be enumerated in a strongly-typed way. (Both
IEnumerable<T> already extend
IEnumerable, so it's not adding anything on that front.)
Now, having a strongly-typed
IQueryable allows LINQ to SQL (etc) to be strongly typed - otherwise you couldn't write
Where clauses etc without casting. The actual LINQ methods involved are in the
Queryable type, largely mirroring the
Enumerable methods but taking expression trees instead of delegates. (If you haven't used expression trees before, they're basically data structures describing the code - whereas a delegate is the code itself. So you can execute a delegate, but you can examine an expression tree to see what it would do.)
Use IQueryable if you want to translate a linq query to an expression tree (System.Linq). From an expression tree you can easily translate your LINQ query to another language (SQL for Linq To SQL. Another classic example is Linq to Google where you want this query :
var searchResult = from result in Google.Repository where result.Equals("i love linq") select result;
To translate to this url :
Then you parse the page to get the results.
- Explain in small words why IQueryable<T> is needed
- LINQ Source Code Available
- .NET 4 Code Contracts: "requires unproven: source != null"
- Can Someone Explain This MSDN Code To Me In English?
- creating Linq to sqlite dbml from DbLinq source code
- How best to optimise this small bit of c# Linq code
- source code for LINQ 101 samples
- I would like others to explain this piece of code to me
- Explain line of code specifically where it says t
- List or Array of String Contain specific word in Html Source Code
- c# Linq or code to extract groups from a single list of source data
- Convert string to int in one line of code using LINQ
- Code equivalent to the 'let' keyword in chained LINQ extension method calls
- Value cannot be null. Parameter name: source
- Linq code to select one item
- C# - code to order by a property using the property name as a string
- How do I find the text within a div in the source of a web page using C#
- Roslyn failed to compile code
- Entity-framework code is slow when using Include() many times
- The data source does not support server-side data paging
- How are people unit testing code that uses Linq to SQL
- Entity Framework, Code First and Full Text Search
- What does this C# code with an "arrow" mean and how is it called?
- How to resolve Value cannot be null. Parameter name: source in linq?
- The source contains no DataRows
- Could not find an implementation of the query pattern for source type 'System.Data.Entity.DbSet'
- How to count the number of code lines in a C# solution, without comments and empty lines, and other redundant stuff, etc?
- Is there an IEnumerable implementation that only iterates over it's source (e.g. LINQ) once?
- Entity Framework 6 Code First Custom Functions
- LINQ query to perform a projection, skipping or wrapping exceptions where source throws on IEnumerable.GetNext()
- Linq distinct problem
- How to do an update with Linq, Lambda and EF
- Where predicate behavior when no element matches the condition
- How to code summary row in ASP.NET Razor table?
- *Right* outer join in LINQ
- Order IList with field name in argument
- LINQ - join the highest rank picture of a product that has many pictures
- Entity Framework Non static method needs a target. Null values in Lambda
- Linq query on the maximum value of 2 fields
- Entity Framework - "All" method
- Sort Linq result in alphabetical order
- linq union of two lists
- Finding records with similar and distinct fields
- Fluent API relationships: one to one or zero relationsip
- ASP.NET Core Linq
- Calling generic method with a type argument known only at execution time
- Create LINQ Association without Foreign Keys
- Select multiple fields in lambda expression
- SQL Join table and SUM values
- Advice on basic Search Function