Click here to Skip to main content
13,766,591 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
Hi
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 });
Posted 5 days ago
Updated 22hrs ago

1 solution

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

Solution 1

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

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
Web05-2016 | 2.8.181114.1 | Last Updated 15 Nov 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

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