Converting Func <T> to <Func <T>> expression for known T

How would I convert Func<T>

to Expression<Func<T>>

without creating the expression itself? I want to do this for the famous T

i.e. For closed type.

For example,

class Person 
{
  public static Func<Person> Factory { get { return () => new Person(); } }

  public static Expression<Func<Person>> ToExpression(Func<Person> personFactory)
  {
    // this is what I am asking
  }
}

      

+3
c # .net


source to share


No one has answered this question yet

See similar questions:

8
Reverse expression <Func <T, TResult >>. Compile ()?
6
Is there a library that can decompile a method into an expression tree with CLR 4.0 support?
2
Where is the hidden selection from TDelegate in the <tdelegate> expression declared?

or similar:

1273
How can I convert a byte array to a hex string and vice versa?
1270
Why not inherit from List <T>?
891
Why are you using Expression <Func <T>> and not Func <T>?
875
How can I convert UTF-8 byte [] to string?
681
Func versus action versus predicate
410
Func delegate with no return type
119
Convert string to C # type
nine
Get the actual return type from Expression <Func <T, object >>
7
Is it possible to convert the expression <Func <T, bool >> to the expression <Func <MyType, bool >>?
0
Convert expression <Func <TProperty>> to Func <TObject, TProperty> where TObject is known



All Articles
Loading...
X
Show
Funny
Dev
Pics