コード例 #1
0
 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));
     }
 }
コード例 #2
0
 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));
     }
 }
コード例 #3
0
 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));
     }
 }
コード例 #4
0
 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));
     }
 }