I have a pure theoretical question.
When do you use Expression<TDelegate>
, and when do you use just the TDelegate
?
Example:
Func<string> myDelegate = () => "Hello World";
Expression<Func<string>> myExpression = () => "Hello World";
Both compile into usable code, and I can call both with the following:
var delegateResult = myDelegate();
var expressionResult = myExpression.Compile()();
So my question is.. What is the use of Expression<TDelegate>
and what would be a situation for preferring using it over the TDelegate
directly?