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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:08:06+00:00 2026-05-14T14:08:06+00:00

I have a class, Users . Users has a UserId property. I have a

  • 0

I have a class, Users.

Users has a UserId property.

I have a method that looks something like this:

static IQueryable<User> FilterById(this IQueryable<User> p, Func<int, bool> sel)
{
   return p.Where(m => sel(m.UserId));
}

Inevitably, when I call the function:

var users = Users.FilterById(m => m > 10);

I get the following exception:

Method ‘System.Object DynamicInvoke(System.Object[])’ has no
supported translation to SQL.

Is there any solution to this problem? How far down the rabbit hole of Expression.KillMeAndMyFamily() might I have to go?

To clarify why I’m doing this: I’m using T4 templates to autogenerate a simple repository and a system of pipes. Within the pipes, instead of writing:

new UserPipe().Where(m => m.UserId > 10 && m.UserName.Contains("oo") && m.LastName == "Wee");

I’d like to generate something like:

new UserPipe()
  .UserId(m => m > 10)
  .UserName(m => m.Contains("oo"))
  .LastName("Wee");
  • 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-14T14:08:06+00:00Added an answer on May 14, 2026 at 2:08 pm

    Let’s take UserId as an example. You want to write:

    new UserPipe().UserId(uid => uid > 10);
    

    and want this to be the same as:

    new UserPipe().Where(user => user.UserID > 10);
    

    What you need to do is to take the expression tree of the first version and translate it to the second version.


    So, first change the signature of UserId to accept an expression tree instead of a compiled lambda:

    public static IQueryable<User> UserId(
        IQueryable<User> source, Expression<Func<int, bool>> predicate)
    

    Then, write a method that converts the first expression tree to the second version. Let’s have a look at the two expression trees:

    Input:

            Lambda
             uid
              |
           BinaryOp
              >
        /            \
    Parameter     Constant
       uid           10
    

    Output:

             Lambda
              user
                |
            BinaryOp
                >
         /            \
     Property         Constant
      UserID             10
         | 
    Parameter
       user
    

    As you can see, all you need to do is take the body of the lambda, recursively replace all occurrences of the parameter uid with the property UserIdon the parameter user and create a new lambda expression with the transformed body and the parameter user.

    You can use an ExpressionVisitor to do the replacement.

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

Sidebar

Ask A Question

Stats

  • Questions 502k
  • Answers 502k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This article discusses the cause and solution to this error.… May 16, 2026 at 2:36 pm
  • Editorial Team
    Editorial Team added an answer If you are using Linq to SQL (or any similar… May 16, 2026 at 2:36 pm
  • Editorial Team
    Editorial Team added an answer Generally I think it is best to just try opening… May 16, 2026 at 2:36 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have a User table defined like this: CREATE TABLE Users( UserId int IDENTITY(1,1)
I have an entity called User which can have a list of other Users
I have this domain hierarchy: User -> EntityWithAuditDate -> Entity Here is the domain:
I have a table with records that has delete links. Basically I followed the
I have a Java web application that has a 'disconnected' Java Swing desktop app.
Idea: I want to make smth like real time electronic blackboard. Many users have
I am working with some tables where I want the C# class to have
Using S#arp Architecture 1.0RC... I have a controller that never seems to update one
I have a JAX-RPC web service that I am attempting to consume using Spring.
I have a base LoggedEvent model and a number of subclass models like follows:

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.