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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:19:09+00:00 2026-05-13T12:19:09+00:00

I was playing around with expression trees and various Linq syntax. I wrote the

  • 0

I was playing around with expression trees and various Linq syntax. I wrote the following:

using (NorthwindDataContext DB = new NorthwindDataContext())
        {
            DataLoadOptions dlo = new DataLoadOptions();

            // Version 1
            dlo.AssociateWith<Customer>(c => c.Orders.Where(o => o.OrderID < 10700).Select(o => o)); 

            // Version 2
            dlo.AssociateWith<Customer>(c => from o in c.Orders
                                             where o.OrderID < 10700
                                             select o);
        }

The Version 1 method returns an error saying “The operator ‘Select’ is not supported in Subquery.”

While Version 2 runs just fine. From what I understand I am writing the exact same thing, but one is with the “dot” notation syntax and the other is query expression syntax.

Am I missing something here? Why the error on one but not the other “if” they are in fact the same query?

  • 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-13T12:19:09+00:00Added an answer on May 13, 2026 at 12:19 pm

    To expand on Daniel’s answer, the select o is known as a degenerate query expression – and it’s removed by the C# compiler. So your query is translated to:

    c.Orders.Where(o => o.OrderID < 10700)
    

    Note that without the where clause, however, the compiler would still include the Select call, so:

    from o in c.Orders
    select o
    

    is translated to

    c.Orders.Select(o => o)
    

    From section 7.15.2.3 of the language spec:

    A degenerate query expression is one
    that trivially selects the elements of
    the source. A later phase of the
    translation removes degenerate queries
    introduced by other translation steps
    by replacing them with their source.
    It is important however to ensure that
    the result of a query expression is
    never the source object itself, as
    that would reveal the type and
    identity of the source to the client
    of the query. Therefore this step
    protects degenerate queries written
    directly in source code by explicitly
    calling Select on the source. It is
    then up to the implementers of Select
    and other query operators to ensure
    that these methods never return the
    source object itself.

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

Sidebar

Related Questions

I've been playing around with Expression Trees. I have the following simple method that
I was playing around with DynamicMethod and Expression Trees ' Compilation (which uses DynamicMethod
I'm just starting out playing around with Linq Expressions and I've hit a wall.
While playing around with regexps in Scala I wrote something like this: scala> val
I'm playing around with quotations and I can't see an expression pattern for type
I was playing around with .Net reflector today and realized that Miicrosoft's entire Expression
Playing around with generating text randomly with each page refresh using php. Is there
I was playing around with testing using machine specifications and there is something that
I've been playing around with the Notepad++ regular expression engine, but there's something I
I'm very new to javascript and have been playing around with regular expressions. I'm

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.