Is there anyway I can update an EF entity by only having the name of the column I need to update and its value:
So given the following data inside my webapi controller:
string colName = 'firstName';
string colValue = 'Sam';
In my EF data retrieval, instead of
var user = db.Users.Where(x => x.firstName == colValue);
can I do something like
var user = db.Users.Where(x => x.colName == x.colValue);
and the somehow update this give column, so something like:
user.colName = colValue;
instead of
user.firstName = colValue;
I have researched Reflection quite a bit but I'm not sure where to begin or if such a task is even possible.
Any pointers, recommendations or suggestions would be greatly appreciated!
Aucun commentaire:
Enregistrer un commentaire