Reputation: 18423
I'm wondering about preparing generic partial view (or HTML helper) which could generate the table based on view model members and its metadata.
It should look similar to this: C# reflection use variable as object.[var]
Is it a good idea or I should forget about it and every time write the code manually because reflection would be too slow?
Are there any tools / add-ons which are able to generate such a code from a view model?
Upvotes: 1
Views: 3744
Reputation: 9281
There's nothing wrong (per se) with using reflection in your views and I seriously doubt you'd notice any performance issues with it; however, I would always recommend trying to encapsulate the behavior in an HTML helper if possible as there are certain benefits you'll gain from doing it that you otherwise wouldn't, these are:
Upvotes: 6