I'm struggling in updating an object with the given key only.
right now i can update using this:
public class Person {
public int Id {get;set;}
public string Name {get;set;}
public string Highest {get;set;}
public ..... (so many more)
}
this is what im using.
var model = db.Person.Find(1);
model.Highest = "20 meters";
what i want for it is to behave like an array where i will only update the data based on key like:
var key = "Highest";
var model = db.Person.Find(1);
model[key] = "20 meters";
so that i can use it as a function
public Person UpdateData(Person model,string key,string newvalue){
model[key] = newvalue;
return model;
}
im think of converting it to array first then update then convert back to object. but i cant find a way to convert it into array.
do you have any suggestion?