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
23
votes
5 answers

Cannot implicitly convert type IEnumerable to IQueryable

Obfuscated Scenario: A person has zero, one or many pets. Using Linq to Sql, the need is to get an IQueryable list of pets for the given personID. Here's the poorly mangled/butchered/obfuscated portion of the ERD: Code: public IQueryable
p.campbell
  • 98,673
  • 67
  • 256
  • 322
23
votes
2 answers

LINQ OrderBy not ordering .. changing nothing .. why?

Any idea why the LINQ OrderBy is not working in following code, (have no errors but method does not sort ...) First my own type public class IQLinksView { public int id { get; set; } public int catid { get; set; } public…
user1415838
  • 233
  • 1
  • 2
  • 5
22
votes
2 answers

Implement IQueryable wrapper to translate result objects

Update 2013-08-22: 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. It is still not fully working though. If I understand the tutorial correctly, the…
cyan902
  • 291
  • 1
  • 2
  • 8
21
votes
3 answers

Declaring an empty Queryable?

How do I declare such a variable? var rData = from nc in ctx.NEWSLETTER_CLIENTS join ni in ctx.NEWSLETTER_INDICES on nc.INDEX_NUM equals ni.INDEX_NUM …
Shai
  • 25,159
  • 9
  • 44
  • 67
19
votes
1 answer

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. The first is because different LINQ providers could behave differently, and this difference should be contained within…
Dale K
  • 25,246
  • 15
  • 42
  • 71
19
votes
5 answers

How can I write a clean Repository without exposing IQueryable to the rest of my application?

So, I've read all the Q&A's here on SO regarding the subject of whether or not to expose IQueryable to the rest of your project or not (see here, and here), and I've ultimately decided that I don't want to expose IQueryable to anything but my Model.…
mmcdole
  • 91,488
  • 60
  • 186
  • 222
18
votes
3 answers

IQueryable vs. IEnumerable in the repository pattern , lazy loading

I have read some articles that state that IEnumerable used to mimic stored procedures or restrict your database. Lost lazy loading ability on the external provider. Where as IQueryable to give developers more flexibility. Lazy loading is there. In…
Milan Mendpara
  • 3,091
  • 4
  • 40
  • 60
18
votes
2 answers

Cannot convert IQueryable<> to IOrderedQueryable error

I have the following LINQ code: var posts = (from p in db.Posts .Include("Site") .Include("PostStatus") where p.Public == false orderby p.PublicationTime select p); if (!chkShowIgnored.Checked)…
Daniel Magliola
  • 30,898
  • 61
  • 164
  • 243
17
votes
3 answers

Force an IQueryable to execute?

I have a method that 'has no translation to SQL' that I want to perform on an IQueryable, is there a way to force the IQueryable to execute without having to store it in some intermediate class?
Kirschstein
  • 14,570
  • 14
  • 61
  • 79
17
votes
5 answers

how can I convert IQueryable to string?

I do a sql query which returns a string - service name. this is the query: IQueryable query = from Comp in ServiceGroupdb.ServiceGroupes where (Comp.GroupID == groupID) select…
thechmodmaster
  • 709
  • 2
  • 7
  • 18
17
votes
1 answer

IEnumerable and IQueryable clarification?

After reading this question, I need to clear up some things. IQueryable custs = from c in db.Customers where c.City == "" select c; IEnumerable custs = from c in db.Customers where c.City == "" select…
Royi Namir
  • 144,742
  • 138
  • 468
  • 792
16
votes
3 answers

Unit Test IQueryable

I am trying to write a unit test for a method which takes an IQueryable collection. How should I instantiate the collection in my unit test before I pass it to the method for test? This is the default code in my test IQueryable Items = null;…
Adrian S
  • 1,007
  • 4
  • 12
  • 26
16
votes
5 answers

LINQ: How to remove element from IQueryable

How do you loop through IQueryable and remove some elements I don't need. I am looking for something like this var items = MyDataContext.Items.Where(x => x.Container.ID == myContainerId); foreach(Item item in items) { if(IsNotWhatINeed(item)) …
Aximili
  • 28,626
  • 56
  • 157
  • 216
16
votes
2 answers

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 { get; set; } public virtual ICollection Bars { get; set; } } public class Bar { public int Id { get;…
Iain Galloway
  • 18,669
  • 6
  • 52
  • 73
15
votes
2 answers

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, which would (not that surprising) get / set the count of the queryable or enumerable parameter. If…
Raphaël Althaus
  • 59,727
  • 6
  • 96
  • 122
1 2
3
97 98