public void Put(dynamic value) { var db = new MyContext(); int id = (int)value.ID; Employee e = db.Employee.SingleOrDefault(r => r.ID == id); foreach (JProperty prop in value) { if (prop.Name != "ID" && prop.Name != "") { PropertyInfo pi = e.GetType().GetProperty(prop.Name); if (pi.CanWrite) { JToken jt = (JToken)prop.Value; var val = Convert.ChangeType(jt, pi.PropertyType); pi.SetValue(e, val, null); } } } db.SaveChanges(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)