Questions tagged [iqueryable]

.NET Framework Interface, providing functionality to evaluate queries against a specific data source wherein the type of the data is not specified.

The IQueryable interface is intended for implementation by query providers. It is only supposed to be implemented by providers that also implement IQueryable(Of T). If the provider does not also implement IQueryable(Of T), the standard query operators cannot be used on the provider's data source.

The IQueryable interface inherits the IEnumerable interface so that if it represents a query, the results of that query can be enumerated. Enumeration causes the expression tree associated with an IQueryable object to be executed. The definition of "executing an expression tree" is specific to a query provider. For example, it may involve translating the expression tree to an appropriate query language for the underlying data source. Queries that do not return enumerable results are executed when the Execute method is called.

http://msdn.microsoft.com/en-us/library/system.linq.iqueryable.aspx

1457 questions
12
votes
2 answers

ASP.MVC: Repository that reflects IQueryable but not Linq to SQL, DDD How To question

I want to create a DDD repository that returns IQueryable Entities that match the Linq to SQL underlying classes, minus any relations. I can easily return Entities minus the relations with a Linq select new {field, field, ... } projection. How do…
Zachary Scott
  • 20,968
  • 35
  • 123
  • 205
11
votes
4 answers

Extend IQueryable Where() as OR instead of AND relationship

I am using my own extension methods of IQueryable<> to create chainable queries such as FindAll().FindInZip(12345).NameStartsWith("XYZ").OrderByHowIWantIt() etc. which then on deferred execution creates a single query based on my extension methods…
Alex
  • 75,813
  • 86
  • 255
  • 348
11
votes
5 answers

Cast IQueryable to IQueryable

We are trying to cast an instance of IQueryable to an IQueryable, the SpecificEntityObject type is only known at runtime. We have tried using the code below, which does not compile because The type or namespace…
Stuart.Sklinar
  • 3,683
  • 4
  • 35
  • 89
11
votes
1 answer

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

I have one queryable where I have used various Where and WhereBetween statements to narrow the collection down to a certain set. Now I need to add kind of a Where || WhereBetween. In other words, I can't just chain them together like I have up till…
Svish
  • 152,914
  • 173
  • 462
  • 620
11
votes
3 answers

count VS select in LINQ - which is faster?

I'm using IQueryable interfaces throughout my application and defer execution of SQL on the DB until methods like .ToList() I will need to find the Count of certain lists sometimes -without- needing to use the data in the list being counted. I…
Matt Kocaj
  • 11,278
  • 6
  • 51
  • 79
11
votes
4 answers

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 IQueryables and then execute the result as a single query. I tried something like this: var query = from x in ... select…
Jonathan Wood
  • 65,341
  • 71
  • 269
  • 466
11
votes
2 answers

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 objective is make this change preserving the existing code for database access, that is implemented with linq to…
IPValverde
  • 2,019
  • 2
  • 21
  • 38
11
votes
3 answers

Determine the position of an element in an IQueryable

I have a IQueryable which is ordered by some condition. Now I want to know the position of a particular element in that IQueryable. Is there a linq expression to get that. Say for example there are 10 elements in the IQueryable and the 6th element…
San
  • 2,316
  • 4
  • 26
  • 35
11
votes
1 answer

LINQ to Entities does not recognize the method 'System.String get_Item(System.String)' method

I've looked at the various solutions here but none of them seem to work for me, probably because I'm too new to all this and am groping in the dark a bit. In the code below, the object "appointment" contains some basic LDAP information. From a list…
user2283231
  • 125
  • 1
  • 1
  • 6
11
votes
1 answer

IQueryable for Anonymous Types

I use EntityFramework, I'm querying and returning partial data using Anonymous Types. Currently I'm using IQueryable, it works, but I would like to know if this is the proper way to do it or if there is some other returning datatype that…
GibboK
  • 71,848
  • 143
  • 435
  • 658
10
votes
2 answers

Why using Count with IQueryable is considered unfeasible

If I have the following code:- IQueryable list = repository.FindAllPeople; int count = list.Count(); Then is it considered as unfeasible to count IQueryable objects and it is better to use IEnumerable? BR
John John
  • 1
  • 72
  • 238
  • 501
10
votes
2 answers

Does AsQueryable() on ICollection really makes lazy execution?

I am using Entity Framework CodeFirst where I have used Parent Child relations using ICollection as public class Person { public string UserName { get;set} public ICollection Blogs { get; set;} } public class Blog { public int id {…
Emran Hussain
  • 11,551
  • 5
  • 41
  • 48
10
votes
4 answers

IQueryable C# Select

this is my code... but i need select only column to display in my Datagridview. I Need the code to select only some columns.. example Select{t => t.usu_Login, t => t.usu_Login} public List Get(FilterDefinition filter) { var…
MrZerocaL
  • 103
  • 1
  • 1
  • 5
10
votes
2 answers

EF builds EntityCollection, but I (think I) want IQueryable

I have an entity A with a simple navigation property B. For any given instance of A, we expect several related thousand instances of B. There is no case where I call something like: foreach(var x in A.B) { ... } Instead, I'm only interested in…
Larsenal
  • 49,878
  • 43
  • 152
  • 220
10
votes
2 answers

Performing two queries in a single round trip to the database

I have the following code to perform a full-text search. It creates a query, gets the total number of rows returned by that query and then retrieves the actual rows for only the current page. // Create IQueryable var query = from a in…
Jonathan Wood
  • 65,341
  • 71
  • 269
  • 466