public JsonResult EntityByStringTest() { var context = new StoreContext(); var type = Type.GetType("MvcPlayground.Models.Customer"); var entitySet = context.Set(type); var entity = entitySet.Find(2); return Json( entity, JsonRequestBehavior.AllowGet ); }
public dynamic Submit(DryRun dryRun = DryRun.Off) { var context = new StoreContext(); var type = Type.GetType(boundRecord.entityClass); var entitySet = context.Set(type); var entity = entitySet.Find(boundRecord.primaryKey); context.Entry(entity); type.GetProperty(fieldToUpdate).SetValue(entity, newValue); if (dryRun == DryRun.Off) { var saveResult = context.SaveChanges(); if (saveResult > 0) { return boundRecord.primaryKey; } else { return null; } } else { return this; } }
public bool Submit(DryRun dryRun = DryRun.Off) { var context = new StoreContext(); var type = Type.GetType(boundRecord.entityClass); var entitySet = context.Set(type); var entity = entitySet.Find(boundRecord.primaryKey); entitySet.Remove(entity); var result = context.SaveChanges(); if (result > 0) { return true; } return false; }
public object GetEntity(string fqn, dynamic primaryKey) { var context = new StoreContext(); var type = Type.GetType(fqn); var entitySet = context.Set(type); var entity = entitySet.Find(primaryKey); return entity; }