Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6616837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:37:53+00:00 2026-05-25T20:37:53+00:00

1) IQueryable essentially represents a query which when executed will yield a sequence of

  • 0

1) IQueryable essentially represents a query which when executed will yield a sequence of results.

a) I assume we execute query by either directly calling IQueryProvider.Execute ( immediate execution ) and passing in an expression tree or by calling IQueryable.GetEnumerator ( deffered execution )?

b) is it IQueryProvider.Execute that actually converts the expression tree into target language ( say SQL ) and then retrieves the results from a DB?

2)

public class Query<T> : IQueryable<T> ... 
{
              ... 
   public IEnumerator<T> GetEnumerator() 
   {
      return((IEnumerable<T>)this.provider.Execute(this.expression)).GetEnumerator();
   }
}

Query<string> someQuery = new Query<string>();

foreach (var item in someQuery) { ... }

a) In the above example query is executed by foreach calling someQuery.GetEnumerator. I assume that in order for the query to actually get executed, the IQueryProvider.Execute must be called from within someQuery.GetEnumerator( via this.provider.Execute )?

Thank you

EDIT

1)

If the query is returned from a Queryable method, then it is deffered
until GetEnumerator() or Execute() is called.

I realize that queries returned from IQueryable are deffered, but it seems that you’re implying that queries ( those implementing IQueryable ) may also be returned from non-Queryable methods ( in which case they are not deffered )?

2)

This is how LINQ-to-SQL does it. LINQ-to-Entites, however, seems to
bypass IqueryProvider when GetEnumerator() is called since its
ObjectQuery provider already has the target implementation-specific
command tree ready to be executed.

I’ve just began learning Linq to entities, but it seems that ObjectQuery<> represents both a query and a specific provider, while with Linq-to-sql ( don’t know any Linq-to-sql, so I’m just guessing ) a query is represented with IQueryable<> and provider is represented with IQueryProvider?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:37:54+00:00Added an answer on May 25, 2026 at 8:37 pm

    1.a) An IQueryable<T> query is usually executed by calling IEnumerable<T>.GetEnumerator() (more often than not via a foreach loop). You can use IQueryable.Execute() as well, which will also execute the query, but you’ll have to cast the result from the IExecuteResult object that’s returned. If the query is returned from a Queryable method, then it is deffered until GetEnumerator() or Execute() is called.

    1.b) Yes, IQueryProvider.Execute takes an implementation-specific Expression and converts it to the implementation-specific target form, and executes that code on the implementation backing (e.g., database or web service).

    2.a) This is how LINQ-to-SQL does it. LINQ-to-Entites, however, seems to bypass IQueryProvider when GetEnumerator() is called since its ObjectQuery<T> provider already has the target implementation-specific command tree ready to be executed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

public static IQueryable<TResult> ApplySortFilter<T, TResult>(this IQueryable<T> query, string columnName) where T : EntityObject {
I have IQueryable list of objects of type T which I want to transform
I have a huge IQueryable that I want to export directly to Excel for
I need to cast: IQueryable<PARENT> to IQueryable<Child> . IQueryable<PARENT> query = GetParents(); IQueryable<CHILD> result
I have a IQueryable which is ordered by some condition. Now I want to
I have a method that takes an IQueryable. Is there a LINQ query that
I have this Linq Query public IQueryable listAll() { ModelQMDataContext db = new ModelQMDataContext();
So IQueryable allows your queries to be executed at the database level rather than
public IQueryable<T> All() { var session = _sessionFactory.GetCurrentSession(); return FilterByClientId(from r in session.Query<T>() select
IQueryable<double?> query = (from t in ctx.MyList orderby t.MyNums select t.MyNums).Take(1); IQueryable<double> q2 =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.