Working with Asp.Net MVC for quite some time now, but I am stuck on a very strange question. Everytime I create a model I make use of lambda expressions like:
@Html.EditorFor(model=>model.SomeProperty)
Why is Asp.Net MVC using such type of an architecture?
Why cant I just pass in a property using reflection?
Is using lambda expression faster? Because under the hoods what I think is that to get the property name it must be using the reflection.
Lambda > Reflection
Using lambdas you get:
Thanks to lambdas, any API can know a lot of things from the property selector:
In addition, check the method signature (http://msdn.microsoft.com/en-us/library/ee402949(v=vs.108).aspx):
It’s an expression tree rather than a regular lambda. This allows MVC (and again, any API) to manipulate the expression in order to add more behaviors prior to invoking it during run-time, without reflection emit.
Learn more about expression trees: