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.GED.Constants.SoftFluent_Samples_GEDStoreName).Persistence; persistence.CreateStoredProcedureCommand(null, "Document", "Save"); persistence.AddParameter("@Document_Id", this.Id, CodeFluentPersistence.DefaultGuidValue); persistence.AddParameter("@Document_Text", this.Text, default(string)); persistence.AddParameter("@Document_User_Id", this.UserId, CodeFluentPersistence.DefaultGuidValue); persistence.AddParameter("@Document_Title", this.Title, default(string)); persistence.AddParameter("@Document_Directory_Id", this.DirectoryId, CodeFluentPersistence.DefaultGuidValue); persistence.AddParameter("@Document_Reference", this.Reference, default(string)); persistence.AddParameter("@Document_Token", this.Token, default(string)); persistence.AddRawParameter("@Document_IsProcessed", this.IsProcessed); persistence.AddRawParameter("@Document_IsReady", this.IsReady); 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); }
public static void SaveLocalizedValues(SoftFluent.Samples.RedisCache.Category entity, int lcid, bool isDefault, string name) { if ((entity == null)) { throw new System.ArgumentNullException("entity"); } if ((entity.Id.Equals(CodeFluentPersistence.DefaultGuidValue) == true)) { CodeFluent.Runtime.CodeFluentRuntimeException.Throw("invalidEntityKey", "Id", "entity", "SoftFluent.Samples.RedisCache.Category"); } CodeFluent.Runtime.CodeFluentPersistence persistence = CodeFluentContext.Get(SoftFluent.Samples.RedisCache.Constants.SoftFluent_Samples_RedisCacheStoreName).Persistence; persistence.CreateStoredProcedureCommand(null, "Category", "SaveLocalizedValues"); persistence.AddParameter("@entityId", entity.Id, CodeFluentPersistence.DefaultGuidValue); persistence.AddParameter("@Lcid", lcid); persistence.AddRawParameter("@IsDefault", isDefault); persistence.AddParameter("@Name", name, default(string)); System.Data.IDataReader reader = null; try { reader = persistence.ExecuteReader(); SoftFluent.Samples.RedisCache.Category.SaveLocalizedValuesUpdateRowVersion(reader, entity, lcid, isDefault, name); } finally { if ((reader != null)) { reader.Dispose(); } persistence.CompleteCommand(); } }
public static SoftFluent.Samples.GED.Directory LoadById(System.Guid id) { if ((id.Equals(CodeFluentPersistence.DefaultGuidValue) == true)) { return(null); } SoftFluent.Samples.GED.Directory directory = new SoftFluent.Samples.GED.Directory(); CodeFluent.Runtime.CodeFluentPersistence persistence = CodeFluentContext.Get(SoftFluent.Samples.GED.Constants.SoftFluent_Samples_GEDStoreName).Persistence; persistence.CreateStoredProcedureCommand(null, "Directory", "LoadById"); persistence.AddRawParameter("@Id", id); System.Data.IDataReader reader = null; try { reader = persistence.ExecuteReader(); if ((reader.Read() == true)) { directory.ReadRecord(reader, CodeFluent.Runtime.CodeFluentReloadOptions.Default); directory.EntityState = CodeFluent.Runtime.CodeFluentEntityState.Unchanged; return(directory); } } finally { if ((reader != null)) { reader.Dispose(); } persistence.CompleteCommand(); } return(null); }
public virtual bool Delete() { bool ret = false; CodeFluent.Runtime.CodeFluentEntityActionEventArgs evt = new CodeFluent.Runtime.CodeFluentEntityActionEventArgs(this, CodeFluent.Runtime.CodeFluentEntityAction.Deleting, true); this.OnEntityAction(evt); if ((evt.Cancel == true)) { return(ret); } if ((this.EntityState == CodeFluent.Runtime.CodeFluentEntityState.Deleted)) { return(ret); } if ((this.RowVersion == null)) { return(ret); } CodeFluent.Runtime.CodeFluentPersistence persistence = CodeFluentContext.Get(SoftFluent.Samples.GED.Constants.SoftFluent_Samples_GEDStoreName).Persistence; persistence.CreateStoredProcedureCommand(null, "Directory", "Delete"); persistence.AddRawParameter("@Directory_Id", this.Id); persistence.AddParameter("@_rowVersion", this.RowVersion); persistence.ExecuteNonQuery(); this.EntityState = CodeFluent.Runtime.CodeFluentEntityState.Deleted; this.OnEntityAction(new CodeFluent.Runtime.CodeFluentEntityActionEventArgs(this, CodeFluent.Runtime.CodeFluentEntityAction.Deleted, false, false)); ret = true; return(ret); }
public virtual bool Reload(CodeFluent.Runtime.CodeFluentReloadOptions options) { bool ret = false; if ((this.Id.Equals(CodeFluentPersistence.DefaultGuidValue) == true)) { return(ret); } CodeFluent.Runtime.CodeFluentPersistence persistence = CodeFluentContext.Get(SoftFluent.Samples.GED.Constants.SoftFluent_Samples_GEDStoreName).Persistence; persistence.CreateStoredProcedureCommand(null, "Directory", "Load"); persistence.AddRawParameter("@Id", this.Id); System.Data.IDataReader reader = null; try { reader = persistence.ExecuteReader(); if ((reader.Read() == true)) { this.ReadRecord(reader, options); this.EntityState = CodeFluent.Runtime.CodeFluentEntityState.Unchanged; ret = true; } else { this.EntityState = CodeFluent.Runtime.CodeFluentEntityState.Deleted; } } finally { if ((reader != null)) { reader.Dispose(); } persistence.CompleteCommand(); } return(ret); }