tagged [iqueryable]

Cannot convert IQueryable<> to IOrderedQueryable error

Cannot convert IQueryable to IOrderedQueryable error I have the following LINQ code: That last lin

How to get the count from IQueryable

How to get the count from IQueryable I am implementing paging in my GridView. From [this](http://www.codedigest.com/Articles/ASPNET/153_Custom_Paging_for_GridView_using_LINQ.aspx) article, I need two ...

27 Mar at 14:30

List<T> to implement IQueryable<T>

List to implement IQueryable I'm trying to create a mock for my `IRepository` interface: With this implementation: ``` public class RepositoryFake : List, IRepository { public Expression Expression ...

20 Jul at 16:47

IEnumerable<T> and IQueryable<T> clarification?

IEnumerable and IQueryable clarification? After reading [this](https://stackoverflow.com/questions/2876616/returning-ienumerablet-vs-iqueryablet) question, I need to clear up some things. Questions: 1...

9 Jan at 16:0

Determine whether an IQueryable<T> has been ordered or not

Determine whether an IQueryable has been ordered or not Is there a way to know if an `IQueryable` has been ordered (using `OrderBy` or `OrderbyDescending`)? So I know whether to call `OrderBy` or `The...

21 Mar at 08:11

Combine Expressions instead of using multiple queries in Entity Framework

Combine Expressions instead of using multiple queries in Entity Framework I have following generic queryable (which may already have selections applied): Then there is the `Provider` class that looks ...

Concat Two IQueryables with Anonymous Types?

Concat Two IQueryables with Anonymous Types? I've been wrestling with this a little while and it's starting to look like it may not be possible. I want to `Concat()` two `IQueryable`s and then execute...

1 Jul at 01:49

What is the purpose of AsQueryable()?

What is the purpose of AsQueryable()? Is the purpose of `AsQueryable()` just so you can pass around an `IEnumerable` to methods that might expect `IQueryable`, or is there a useful reason to represent...

28 Jun at 14:27

Repository Methods vs. Extending IQueryable

Repository Methods vs. Extending IQueryable I have repositories (e.g. ContactRepository, UserRepository and so forth) which encapsulate data access to the domain model. When I was looking at , e.g. - ...

Repository / IQueryable / Query Object

Repository / IQueryable / Query Object I am building a repository and I've seen in many places 2 reasons not to expose IQueryable outside the repository. 1) The first is because different LINQ provide...

Instantiate empty IQueryable for use with Linq to sql

Instantiate empty IQueryable for use with Linq to sql I need to be able to either have an optional parameter in a Linq query, or be able to assign the query to a var in something like an IF if that op...

How to invoke Expression<Func<Entity, bool>> against a collection

How to invoke Expression> against a collection I have an interface that defines a repository from the Repository pattern: I've implemented it against Entity Framework: ``` class EntityFrameworkReposit...

24 Sep at 03:51

In which cases do I need to create two different extension methods for IEnumerable and IQueryable?

In which cases do I need to create two different extension methods for IEnumerable and IQueryable? Let's say I need an extension method which selects only required properties from different sources. T...

28 Dec at 21:57

Remove OrderBy from an IQueryable<T>

Remove OrderBy from an IQueryable I have a paging API that returns rows a user requests, but only so many at one time, not the entire collection. The API works as designed, but I do have to calculate ...

14 May at 21:2

Use IQueryable.Count<T> with an IEnumerable<T> parameter

Use IQueryable.Count with an IEnumerable parameter imagine a class, let's say for pagination which could be used with an `IList` or an `IQueryable`. That class would have an `int TotalItems` property,...

8 Mar at 16:39

Enumerable.Empty<T>().AsQueryable(); This method supports the LINQ to Entities infrastructure and is not intended to be used directly from your code

Enumerable.Empty().AsQueryable(); This method supports the LINQ to Entities infrastructure and is not intended to be used directly from your code I am getting runtime error > This method supports the ...

How do I mock IQueryable<T>

How do I mock IQueryable I am creating a repository that exposes IQueryable. What is the best way to mock this out for my unit testing? Since I am using RhinoMocks for the rest of my mock objects, I t...

12 Feb at 04:39

Automatically Compile Linq Queries

Automatically Compile Linq Queries We've found that [compiling our Linq queries](http://www.dotnetfunda.com/articles/article469-how-to-improve-your-linq-query-performance-by-5-x-times-.aspx) is much, ...

Exposing EntityFramework 4 entities as IList instead of IObjectSet

Exposing EntityFramework 4 entities as IList instead of IObjectSet I have a 'Customer' POCO entity within my Entity Framework 4 project. I want to expose my Customer entities to my upper layers as a g...

6 Jan at 11:10

ObjectSet wrapper not working with linqToEntities subquery

ObjectSet wrapper not working with linqToEntities subquery for access control purposes in a intensive DB use system I had to implement an objectset wrapper, where the AC will be checked. The main obje...

AutoMapper Project().To() and sorting a child collection

AutoMapper Project().To() and sorting a child collection I have an object graph that I'm loading from a database using EF CodeFirst and AutoMapper into DTOs:- ``` public class Foo { public int Id { g...

23 Apr at 13:15

The provider for the source IQueryable doesn't implement IAsyncQueryProvider

The provider for the source IQueryable doesn't implement IAsyncQueryProvider I have some codes like below, I want to write unit tests my method. But I'm stuck in async methods. Can you help me please ...

C#, Linq2Sql: Is it possible to concatenate two queryables into one?

C#, Linq2Sql: Is it possible to concatenate two queryables into one? where I have used various [Where](http://msdn.microsoft.com/en-us/library/system.linq.queryable.where.aspx) and [WhereBetween](http...

Implement IQueryable wrapper to translate result objects

Implement IQueryable wrapper to translate result objects After having a look at the 'Building an IQueryable provider series' (thanks for the link!) I got a bit further. I updated the code accordingly....