Beispiel #1
0
 public Table Save(Table table)
 {
     Table ret = table;
     if (table.ConnectionName != ConnectionName)
     {
         throw new Exception("Cannot insert an entry into a table into the database connection that it was not specified for.");
     }
     if (table.LoadStatus == LoadStatus.Partial)
         ret = table;
     else
     {
         if (table.IsSaved)
         {
             if (table.LoadStatus == LoadStatus.Complete)
             {
                 Table orig = table.LoadCopyOfOriginal(this);
                 bool abort = false;
                 ConnectionPoolManager.RunTriggers(this, orig, table, ConnectionPoolManager.TriggerTypes.PRE_UPDATE, out abort);
                 if (!abort)
                 {
                     ret = Update(table);
                     ConnectionPoolManager.RunTriggers(this, orig, ret, ConnectionPoolManager.TriggerTypes.POST_UPDATE, out abort);
                 }
             }
             else
                 ret = table;
         }
         else
         {
             bool abort = false;
             ConnectionPoolManager.RunTriggers(this, null, table, ConnectionPoolManager.TriggerTypes.PRE_INSERT, out abort);
             if (!abort)
             {
                 ret = Insert(table, false);
                 ConnectionPoolManager.RunTriggers(this, null, ret, ConnectionPoolManager.TriggerTypes.POST_INSERT, out abort);
             }
         }
     }
     if (!ret.IsProxied)
         ret = (Table)LazyProxy.Instance(ret);
     return ret;
 }