public rList <MyEntity> List(pList prms) { try { var db = new ModelTest(); return(db.MyEntities.OrderBy(p => p.Id).Filter(prms)); } catch (Exception ex) { return(new rList <MyEntity>(ex)); } }
public rValue <MyEntity> Update(MyEntity prms) { try { var db = new ModelTest(); var ent = db.MyEntities.Single(p => p.Id == prms.Id); ent.Name = prms.Name; db.SaveChanges(); return(new rValue <MyEntity>(ent)); } catch (Exception ex) { return(new rValue <MyEntity>(ex)); } }
public rValue <int> Delete(MyEntity prms) { try { var db = new ModelTest(); var ent = db.MyEntities.Single(p => p.Id == prms.Id); db.MyEntities.Remove(ent); db.SaveChanges(); return(new rValue <int>(prms.Id)); } catch (Exception ex) { return(new rValue <int>(ex)); } }
public rValue <MyEntity> Add(MyEntity prms) { try { var db = new ModelTest(); var ent = new MyEntity() { Name = prms.Name }; db.MyEntities.Add(ent); db.SaveChanges(); return(new rValue <MyEntity>(ent)); } catch (Exception ex) { return(new rValue <MyEntity>(ex)); } }