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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:44:36+00:00 2026-05-16T03:44:36+00:00

Lets say i have : Func<Customer,bool > a = (c) => c.fullName == John;

  • 0

Lets say i have :

 Func<Customer,bool > a = (c) => c.fullName == "John";

now i want to convert to expressiontree any way to do that ?

i know i can define it from the first place as expressiontree but the situation i have is different because i must concatenate some lambda expressions first then pass it to a method which take expressiontree, doing so result in compile time error!

example:

        Func<Customer, bool> a = (c) => c.fullName == "John";
        Func<Customer, bool> b = (c) => c.LastName == "Smith";
        Func<Customer, bool> final = c => a(c) && b(c); 

now i want to pass final to a method which takes

ExpressionTree<Func<Customer,bool >>

it gives compile time error

thanks in advance

  • 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-16T03:44:37+00:00Added an answer on May 16, 2026 at 3:44 am

    You cannot do that. A variable of type Func<...> is a delegate, which is basically like a pointer to a memory location that contains the compiled code for the lambda expression. There is no functionality in .NET to turn already-compiled code back into an expression tree.

    Depending on what you are trying to do, maybe you can contend with an incomplete solution: create an expression tree that calls the delegates. Since I don’t know anything about the method to which you want to pass the expression tree, I have no idea whether this is at all a feasible solution for you.

    Summary: If you want the complete expression tree of all the expressions, you need to make sure that they are expression trees right from the start. As soon as you compile it into a delegate, the expression tree is lost.

    Once you’ve made sure that they are expression trees, you can combine them using something like the following:

    Expression<Func<Customer, bool>> a = c => c.FullName == "John";
    Expression<Func<Customer, bool>> b = c => c.LastName == "Smith";
    
    var cp = Expression.Parameter(typeof(Customer), "c");
    
    var ai = Expression.Invoke(a, cp);
    var bi = Expression.Invoke(b, cp);
    
    var final = Expression.Lambda<Func<Customer, bool>>(
        Expression.AndAlso(ai, bi), cp);
    

    Of course, this uses the AndAlso operator (&&); you can also use OrElse for || etc.

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

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Maybe you could use this in the beginning of the… May 17, 2026 at 12:42 am
  • Editorial Team
    Editorial Team added an answer There is no Apple-supported way to downgrade, so I'd never… May 17, 2026 at 12:42 am
  • Editorial Team
    Editorial Team added an answer \b is a transition between a non-word character and a… May 17, 2026 at 12:42 am

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

So, lets say I have the following expression in C#: Expression<Func<string>> expr = ()
Lets say I have a sample workflow that does the following: Receive something Run
Lets say I have the following one-to-many relationship: Site has many Users User belongs
Lets say I have something called Stuff in my database, with a property called
Let's say I have o: context [ f: func[message /refine message2][ print [message] if
Let's say I have an interface IMyInterface<T> that simply describes one function: public interface
Let's say I have a list of objects, and I want to sort it
Lets say i have a form which have the following : Name:TextBox Email:TextBox Age:TextBox
Lets say i have a text file with following content: Hello! How are you?
Lets say I have 2 tables: 1 with users and another one which keeps

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.