What’s the difference between IQueryable and IEnumerable [duplicate]

IEnumerable<T> represents a forward-only cursor of T. .NET 3.5 added extension methods that included the LINQ standard query operators like Where and First, with any operators that require predicates or anonymous functions taking Func<T>. IQueryable<T> implements the same LINQ standard query operators, but accepts Expression<Func<T>> for predicates and anonymous functions. Expression<T> is a compiled expression … Read more

Using IQueryable with Linq

Marc Gravell’s answer is very complete, but I thought I’d add something about this from the user’s point of view, as well… The main difference, from a user’s perspective, is that, when you use IQueryable<T> (with a provider that supports things correctly), you can save a lot of resources. For example, if you’re working against … Read more

What is the difference between IQueryable and IEnumerable?

First of all, IQueryable<T> extends the IEnumerable<T> interface, so anything you can do with a “plain” IEnumerable<T>, you can also do with an IQueryable<T>. IEnumerable<T> just has a GetEnumerator() method that returns an Enumerator<T> for which you can call its MoveNext() method to iterate through a sequence of T. What IQueryable<T> has that IEnumerable<T> doesn’t … Read more

Dynamic LINQ OrderBy on IEnumerable / IQueryable

Just stumbled into this oldie… To do this without the dynamic LINQ library, you just need the code as below. This covers most common scenarios including nested properties. To get it working with IEnumerable<T> you could add some wrapper methods that go via AsQueryable – but the code below is the core Expression logic needed. … Read more

Returning IEnumerable vs. IQueryable

Yes, both will give you deferred execution. The difference is that IQueryable<T> is the interface that allows LINQ-to-SQL (LINQ.-to-anything really) to work. So if you further refine your query on an IQueryable<T>, that query will be executed in the database, if possible. For the IEnumerable<T> case, it will be LINQ-to-object, meaning that all objects matching … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)