이것은 내가 데이터베이스에서 값을 업데이트하는 방법에 대한 간단한 예는 다음과 같습니다이름으로 속성에 액세스하는 방법은 무엇입니까?
var context = new dbEntities();
var car = context.CarTable.Where(p => p.id == id).FirstOrDefault();
car.Make = "Volvo";
context.SaveChanges();
그러나, 지금해야 할 일을 대신 이름으로 재산을 얻는 것입니다. 이것이 이론에서 내가하고자하는 것입니다 :
var context = new dbEntities();
var car = context.CarTable.Where(p => p.id == id).FirstOrDefault();
**car["Make"] = "Volvo";**
context.SaveChanges();
이것은 EF에서 가능합니까?
리플렉션을 통해이 작업을 수행 할 수 있지만 매우 느린 (http://stackoverflow.com/questions/1196991/get-property-value-from-string-using-reflection-in -c-sharp 및 http://stackoverflow.com/questions/619767/net-reflection-set-object-property) – derape
그리고 왜 그렇게하고 싶습니까? – Satpal
이름으로 등록 정보가 필요한 이유가 무엇입니까? – Bas