samedi 11 juin 2016

MVC Entity Model using variables in property names (reflection?)

trying to understand the best way of updating an MVC Entity model using the name of a field in a variable. Suppose I have a table with date, field1,field2 field3 and so on. I need to add/update the table based on the field contained in a variable.

Something like:

n = 1 Model.field[n] = thisval

n = 3 Model.field[n] = otherval

I'm guessing I have to use something like reflection to assign a name attribute to each property in the model and then use it as a reference to the model?

Am I on the right track? Any suggestions/pointers would be greatly appreciated. thanks





Aucun commentaire:

Enregistrer un commentaire