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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:33:28+00:00 2026-05-15T10:33:28+00:00

I have an IQueryable (PartHistories) that will return a set of objects. I have

  • 0

I have an IQueryable (PartHistories) that will return a set of objects. I have an enum called Phase that alters the query, like this (rc is a list):

            var query = this.PartHistories;
            if ( Phase.Repair == _Phase )
            {
                query = query.Where( ph => ph.RemovedInRepair == false );
            }
            else
            {
                query = query.Where( ph => ph.PartPhaseID != ( int )Phase.Repair );
            }
            rc.AddRange( query
                .ToList( ) );

This works.

Now, the object in question (PartHistory) has a property, PartPhase, which casts PartPhaseID as Phase. This code, however, does NOT work (the change is in the Phase.Repair line):

            var query = this.PartHistories;
            if ( Phase.Repair == _Phase )
            {
                query = query.Where( ph => ph.RemovedInRepair == false );
            }
            else
            {
                query = query.Where( ph => ph.PartPhase != Phase.Repair );
            }
            rc.AddRange( query
                .ToList( ) );

At the AddRange, the exception is “the member ‘PartPhase’ is not supported.

Finally, the following code works, but in this case, the Where is the extension of List and (I think) applies after all the PartHistories have been collected:

          if( Phase.Repair == _Phase )
          {
              rc.AddRange( this.PartHistories.ToList( )
                  .Where( ph => ph.RemovedInRepair == false ) );
          }
          else
          {
              rc.AddRange( this.PartHistories.ToList( )
                  .Where( ph => ph.PartPhase != Phase.Repair ) );
  • 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-15T10:33:29+00:00Added an answer on May 15, 2026 at 10:33 am

    If this is Linq to SQL, then yes, it does not support custom method calls.
    It can translate expressions to SQL queries, but doesn’t know what happens inside your property. So, custom methods and properties are not convertible to SQL.

    If you could make an Expression<Func<PartHistory, PartPhase>>, which would do the same thing your property does (without calling custom methods), then it would work.

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

Sidebar

Related Questions

I have two tables that I have joined in a query like this IQueryable<Auction>
If I have a query like this: String Category = HttpContext.Current.Request.QueryString[Product].ToString(); IQueryable<ItemFile> pressReleases =
I have a Menu class that has a IQueryable property called WebPages. In the
I have a Linq query that returns an object of the type IQueryable<ClassX> .
I have C# Lambda linq query as follow: public IQueryable<CtArticleDetail> GetArticleDetailsByTagNames(string tagNames) { return
Suppose I have an IQueryable<T> expression that I'd like to encapsulate the definition of,
I need help constructing a linq query that will return a list of usernames
I have an IQueryable object like this var persons = from m in db.Persons
I have a query that returns IQueryable, my query consists of join. the end
I have a compiled query that returns an IQueryable<tblMyTable> . If I execute the

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.