コード例 #1
0
 public static void DeleteConfig(Config c)
 {
     using (var ctx = new BMIKidsEntities(BaseDataProvider.ConnectionString))
     {
         try
         {
             c.MarkAsDeleted();
             ctx.Configs.ApplyChanges(c);
             ctx.SaveChanges();
             c.AcceptChanges();
         }
         catch (Exception ex)
         {
             if (ex.InnerException != null)
                 throw ex.InnerException;
             throw;
         }
     }
 }
コード例 #2
0
        public static void SaveConfig(Config c)
        {
            using (var ctx = new BMIKidsEntities(BaseDataProvider.ConnectionString))
            {
                try
                {
                    if (c.ChangeTracker.State == ObjectState.Unchanged)
                        c.MarkAsModified();

                    ctx.Configs.ApplyChanges(c);
                    ctx.SaveChanges();
                    c.AcceptChanges();
                }
                catch (Exception ex)
                {
                    if (ex.InnerException != null)
                        throw ex.InnerException;
                    throw;
                }
            }
        }