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

  • SEARCH
  • Home
  • 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 6625845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:49:21+00:00 2026-05-25T21:49:21+00:00

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

  • 0

1)

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>();

someQuery.Expression holds the expression tree associated with this particular instance of IQueryable and thus describes how to retrieve the initial sequence of items. In the following example initialSet variable actually contains a sequence of strings:

    string[] initialSet = { };
    var results1 = from x in initialSet
                   where ...
                   select ...;

a) Can someQuery also contain a sequence of strings, or can it only contain instructions ( in the form of expression tree ) on how to get this initial sequence of strings from some DB?

b) I assume that even if someQuery actually contains an initial sequence of strings, it is of no use to Where and Select operators, since they won’t ever operate on this sequence of strings, but instead their job is only to build queries or request queries to be executed ( by calling IQueryProvider.Execute)? And for this reason someQuery must always contain an expression tree describing how too get the initial sequence of strings, even if someQuery already contains this initial sequence?

Thank you

EDIT:

c) The way I understood your post is that query provider may contain information about describing the table or at least describing particular DB rows which initial query needs to retrieve. But I didn’t interpret your answer as saying that query provider may also contain actual elements required by this initial query ( someQuery in our example )?

d) Regardless, I assume even if query provider maintains actual elements, it can only maintain them for initial query? Thus if we apply Linq-to-entity or Linq-to-Sql operators on that initial query, I assume provider will have to query the database. As such, if my assumption are correct then answer to b) would be even if query does contain actual elements, when we call Where on someQuery ( someQuery.Where ),query provider will have to retrieve results from a DB, even if this query provider already contains all the elements of someQuery?

e) I only started learning Linq-to-entities, so my question may be too general, but how does EF handle all of this? In other words, when does ObjectSet<T> returned by some EF API ( such as ObjectContext ), contain actual elements and when does it ( if ever ) contain only logic for retrieving elements from some data source (such as DB)?

f) Also, even if ObjectSet<T> ( returned by say ObjectSet ) does contain actual elements, I assume if we apply Where operator on it ( ObjectSet<T>.Where ), query provider will always have to retrieve results from the DB?

  • 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-25T21:49:22+00:00Added an answer on May 25, 2026 at 9:49 pm

    a) You wouldn’t normally create a Query<T> yourself – a query provider would. It can choose to include whatever information it wants. It’s most likely to just contain the information about what table it’s associated with though.

    b) That’s entirely up to the query provider. As you saw in the other question, the query provider may end up recognizing when it’s reached a Query<T> – so it could know to ask the Query<T> for its strings, if that was appropriate.

    c) The query provider wouldn’t usually contain data itself – but it could do. It’s up to the provider.

    d) The query provider may notice that it’s within a transaction, and that it’s already executed a similar context in the query – it may be able to answer the query from within its cache. It’s up to the query provider.

    e, f) No idea, I’ve never used Entity Framework in anger.

    The answer to almost all of your questions around this is topic is “it’s up to the query provider”. For details about a particular query provider, you should read the documentation for that provider. That should explain when it will make queries etc. It’s unclear what you’re really trying to get out of these questions – but if you’re after a full implementation to study, there are plenty of open source LINQ providers around. You might want to look at NHibernate for example.

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

Sidebar

Related Questions

I have a class ReportingComponent<T> , which has the constructor: public ReportingComponent(IQueryable<T> query) {}
I have this method in my db class public function query($queryString) { if (!$this->_connected)
Basic C# syntax question: So I have this class public class BrandQuery<T> : Query<T>
public class BE_RoomRateService { public IQueryable<RoomRateWithRoomType> RoomRateForAdmin() { var query= from rate in db.BE_RoomRates
i have this in my BlogRepository public IQueryable<Subnus.MVC.Data.Model.Post> GetPosts() { var query = from
I have a IQueryable<SomePOCO> (a LINQ-Entities query, if that matters): public class SomePOCO {
I have the following simple Java code: package testj; import java.util.*; public class Query<T>
public class Test { public static void main(String[] args) { } } class Outer
public class Address { public string ZipCode {get; set;} } public class Customer {
public class doublePrecision { public static void main(String[] args) { double total = 0;

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.