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 6207647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:40:08+00:00 2026-05-24T05:40:08+00:00

I’m trying to create a LINQ provider. I’m using the guide LINQ: Building an

  • 0

I’m trying to create a LINQ provider. I’m using the guide LINQ: Building an IQueryable provider series, and I have added the code up to LINQ: Building an IQueryable Provider – Part IV.

I am getting a feel of how it is working and the idea behind it. Now I’m stuck on a problem, which isn’t a code problem but more about the understanding.

I’m firing off this statement:

QueryProvider provider = new DbQueryProvider();
Query<Customer> customers = new Query<Customer>(provider);

int i = 3;
var newLinqCustomer = customers.Select(c => new { c.Id, c.Name}).Where(p => p.Id == 2 | p.Id == i).ToList();

Somehow the code, or expression, knows that the Where comes before the Select. But how and where?

There is no way in the code that sorts the expression, in fact the ToString() in debug mode, shows that the Select comes before the Where.

I was trying to make the code fail. Normal I did the Where first and then the Select.

So how does the expression sort this? I have not done any change to the code in the guide.

  • 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-24T05:40:09+00:00Added an answer on May 24, 2026 at 5:40 am

    The expressions are “interpreted”, “translated” or “executed” in the order you write them – so the Where does not come before the Select


    If you execute:

            var newLinqCustomer = customers.Select(c => new { c.Id, c.Name})
                                           .Where(p => p.Id == 2 | p.Id == i).ToList();
    

    Then the Where is executed on the IEnumerable or IQueryable of the anonymous type.


    If you execute:

            var newLinqCustomer = customers.Where(p => p.Id == 2 | p.Id == i)
                                           .Select(c => new { c.Id, c.Name}).ToList();
    

    Then the Where is executed on the IEnumerable or IQueryable of the customer type.


    The only thing I can think of is that maybe you’re seeing some generated SQL where the SELECT and WHERE have been reordered? In which case I’d guess that there’s an optimisation step somewhere in the (e.g.) LINQ to SQL provider that takes SELECT Id, Name FROM (SELECT Id, Name FROM Customer WHERE Id=2 || Id=@i) and converts it to SELECT Id, Name FROM Customer WHERE Id=2 || Id=@i – but this must be a provider specific optimisation.

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

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm trying to create an if statement in PHP that prevents a single post
I have thousands of HTML files to process using Groovy/Java and I need to
I am trying to loop through a bunch of documents I have to put
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am trying to understand how to use SyndicationItem to display feed which is
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

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.