public Guid Insert(CommonEntityBase commonObject) { List <SqlParameter> sqlParameters = commonObject.GetProcedureParameters(); Guid newEntityGuid = Guid.Empty; this.BeginTransaction(); try { newEntityGuid = DataAccessProvider.Insert(this.TableName, sqlParameters); if (OnEntityChange != null) { commonObject.PrimaryKey = newEntityGuid; this.OnEntityChange(commonObject, new EntityChangeEventArgs(EntityChangeActionTtype.Insert)); } this.CommitTransaction(); } catch { this.RollbackTransaction(); throw; } return(newEntityGuid); }
public bool Load(Guid entityGuid, CommonEntityBase commonObject) { if (commonObject == null) { throw new Exception("Common object not initialized"); } DataRow loadedDataRow; if (commonObject.HasReadOnlyFields) { loadedDataRow = DataAccessProvider.Load(this.ViewName, entityGuid); } else { loadedDataRow = DataAccessProvider.Load(this.TableName, entityGuid); } return(commonObject.Load(loadedDataRow)); }
public bool Update(CommonEntityBase commonObject) { List <SqlParameter> sqlParameters = commonObject.GetProcedureParameters(); this.BeginTransaction(); try { DataAccessProvider.Update(this.TableName, commonObject.PrimaryKey, sqlParameters); if (OnEntityChange != null) { this.OnEntityChange(commonObject, new EntityChangeEventArgs(EntityChangeActionTtype.Insert)); } this.CommitTransaction(); } catch { this.RollbackTransaction(); throw; } return(true); }