Reputation: 869
Is it possible to get the instance of TModel
from Expression
in the following method?
public void FooBar<TModel, TProperty> MyMethod(
Expression<Func<TModel, TProperty>> expression)
where TModel : ViewModel
{
ViewModel model = ???;
}
Upvotes: 0
Views: 154
Reputation: 203835
There is no instance, and as such there is no way to get the instance that doesn't exist.
The expression is merely an object that says, "If you give me a model, I know how to give you back a property of it." It doesn't actually have a model until you give it a model.
Upvotes: 7