Click here to Skip to main content
13,897,281 members
Rate this:
Please Sign up or sign in to vote.
See more:
I am trying to "print" the expression tree, but with the calculated values in C#.

I have a method:
public string GetElement(Expression<Predicate<T>> match)
   ParameterExpression pe = Expression.Parameter(typeof(T), "s");
            BinaryExpression be = match.Body as BinaryExpression;

            var ExpressionTree = Expression.Lambda<Func<T, bool>>(match.Body, new[] { pe });
            return ExpressionTree;

It shows correctly if I uses GetElement(s => s.Name == "New York") but if I try:

var name = "New York";
 GetElement(s=>s.Name == name) 

I get "s => (s.Name == value(WpfTester.MainWindow+<>c__DisplayClass0_0).name)"

What I have tried:

I have only tried
Expression.Lambda<Func<T, bool>>(match.Body, new[] { pe });
Updated 15-Nov-18 3:01am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

See the LINQString.cs file in my RaptorDB - The Document Store[^] project.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Cookies | Terms of Service
Web06 | 2.8.190306.1 | Last Updated 15 Nov 2018
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100