예제 #1
0
 protected virtual bool BaseSave(bool force)
 {
     if ((this.EntityState == CodeFluent.Runtime.CodeFluentEntityState.ToBeDeleted))
     {
         this.Delete();
         return(false);
     }
     CodeFluent.Runtime.CodeFluentEntityActionEventArgs evt = new CodeFluent.Runtime.CodeFluentEntityActionEventArgs(this, CodeFluent.Runtime.CodeFluentEntityAction.Saving, true);
     this.OnEntityAction(evt);
     if ((evt.Cancel == true))
     {
         return(false);
     }
     CodeFluentPersistence.ThrowIfDeleted(this);
     this.Validate();
     if (((force == false) &&
          (this.EntityState == CodeFluent.Runtime.CodeFluentEntityState.Unchanged)))
     {
         return(false);
     }
     CodeFluent.Runtime.CodeFluentPersistence persistence = CodeFluentContext.Get(SoftFluent.Samples.StoreEnumAsText.Constants.SoftFluent_Samples_StoreEnumAsTextStoreName).Persistence;
     persistence.CreateStoredProcedureCommand(null, "Sample", "Save");
     persistence.AddParameter("@Sample_Id", this.Id, CodeFluentPersistence.DefaultGuidValue);
     persistence.AddParameterAsText("@Sample_Gender", this.Gender, SoftFluent.Samples.StoreEnumAsText.Gender.Male);
     persistence.AddParameterAsText("@Sample_Day", this.Day, SoftFluent.Samples.StoreEnumAsText.Day.None);
     persistence.AddParameter("@_trackLastWriteUser", persistence.Context.User.Name);
     persistence.AddParameter("@_rowVersion", this.RowVersion);
     System.Data.IDataReader reader = null;
     try
     {
         reader = persistence.ExecuteReader();
         if ((reader.Read() == true))
         {
             this.ReadRecordOnSave(reader);
         }
         CodeFluentPersistence.NextResults(reader);
     }
     finally
     {
         if ((reader != null))
         {
             reader.Dispose();
         }
         persistence.CompleteCommand();
     }
     this.OnEntityAction(new CodeFluent.Runtime.CodeFluentEntityActionEventArgs(this, CodeFluent.Runtime.CodeFluentEntityAction.Saved, false, false));
     this.EntityState = CodeFluent.Runtime.CodeFluentEntityState.Unchanged;
     return(true);
 }