/// <summary> /// Get with transaction /// </summary> public PM_ALT_EVENT_TYPE_GRP Get(object entityId, DbTransaction transaction) { ArgumentValidator.CheckForNullArgument(entityId, "entityId"); ArgumentValidator.CheckForNullArgument(transaction, "transaction"); PM_ALT_EVENT_TYPE_GRP PM_ALT_EVENT_TYPE_GRPEntity = null; try { Database db = GetDatabaseInstance(); DbCommand dbCommand = db.GetSqlStringCommand(PM_ALT_EVENT_TYPE_GRPDAO.SqlGet); db.AddInParameter(dbCommand, "@NotiEventGroupID", DbType.Guid, entityId); using (IDataReader dataReader = db.ExecuteReader(dbCommand, transaction)) { if (dataReader.Read()) { PM_ALT_EVENT_TYPE_GRPEntity = ReadEntity(dataReader); } } } catch (Exception ex) { ExceptionPolicy.HandleException(ex, ExceptionPolicy.DataAccessDefaultPolicy); } return(PM_ALT_EVENT_TYPE_GRPEntity); }
private static PM_ALT_EVENT_TYPE_GRP ReadEntity(IDataReader dataReader) { PM_ALT_EVENT_TYPE_GRP PM_ALT_EVENT_TYPE_GRPEntity = new PM_ALT_EVENT_TYPE_GRP(); object value; value = dataReader["NotiEventGroupID"]; if (value != DBNull.Value) { PM_ALT_EVENT_TYPE_GRPEntity.NotiEventGroupID = (Guid?)value; } value = dataReader["EventTypeID"]; if (value != DBNull.Value) { PM_ALT_EVENT_TYPE_GRPEntity.EventTypeID = (Guid?)value; } value = dataReader["NotiGroupID"]; if (value != DBNull.Value) { PM_ALT_EVENT_TYPE_GRPEntity.NotiGroupID = (Guid?)value; } return(PM_ALT_EVENT_TYPE_GRPEntity); }
private void UpdateAll(PM_ALT_EVENT_TYPE_GRP entity, DbTransaction transaction) { ArgumentValidator.CheckForNullArgument(entity, "entity"); ArgumentValidator.CheckForNullArgument(transaction, "transaction"); PersistentPM_ALT_EVENT_TYPE_GRP PM_ALT_EVENT_TYPE_GRPEntity = entity as PersistentPM_ALT_EVENT_TYPE_GRP; try { Database db = GetDatabaseInstance(); DbCommand dbCommand = db.GetSqlStringCommand(PM_ALT_EVENT_TYPE_GRPDAO.SqlUpdate); db.AddInParameter(dbCommand, "@NotiEventGroupID", DbType.Guid, PM_ALT_EVENT_TYPE_GRPEntity.NotiEventGroupID); db.AddInParameter(dbCommand, "@EventTypeID", DbType.Guid, PM_ALT_EVENT_TYPE_GRPEntity.EventTypeID); db.AddInParameter(dbCommand, "@NotiGroupID", DbType.Guid, PM_ALT_EVENT_TYPE_GRPEntity.NotiGroupID); int result = db.ExecuteNonQuery(dbCommand, transaction); if (result == 0) { throw new EntityNotFoundException(); } } catch (Exception ex) { ExceptionPolicy.HandleException(ex, ExceptionPolicy.DataAccessDefaultPolicy); } }
public void Update(PM_ALT_EVENT_TYPE_GRP entity, bool updateAll, DbTransaction transaction) { if (!updateAll) { UpdateSome(entity, transaction); } else { UpdateAll(entity, transaction); } }
public void Update(PM_ALT_EVENT_TYPE_GRP entity, bool updateAll) { if (!updateAll) { UpdateSome(entity); } else { UpdateAll(entity); } }
public void UpdateSome(PM_ALT_EVENT_TYPE_GRP entity) { try { ArgumentValidator.CheckForNullArgument(entity, "PM_ALT_EVENT_TYPE_GRP Entity"); _PM_ALT_EVENT_TYPE_GRPDAO.Update(entity, false); } catch (Exception ex) { ExceptionPolicy.HandleException(ex, ExceptionPolicy.BusinessLogicDefaultPolicy); } }
public void Delete(PM_ALT_EVENT_TYPE_GRP entity) { try { ArgumentValidator.CheckForNullArgument(entity, "PM_ALT_EVENT_TYPE_GRP Entity"); _PM_ALT_EVENT_TYPE_GRPDAO.Delete(entity.NotiEventGroupID); } catch (Exception ex) { ExceptionPolicy.HandleException(ex, ExceptionPolicy.BusinessLogicDefaultPolicy); } }
public PM_ALT_EVENT_TYPE_GRP GetEntity(Guid entityGuid) { PM_ALT_EVENT_TYPE_GRP entity = null; try { ArgumentValidator.CheckForNullArgument(entityGuid, "PM_ALT_EVENT_TYPE_GRP Guid"); entity = _PM_ALT_EVENT_TYPE_GRPDAO.Get(entityGuid); } catch (Exception ex) { ExceptionPolicy.HandleException(ex, ExceptionPolicy.BusinessLogicDefaultPolicy); } return(entity); }
public PM_ALT_EVENT_TYPE_GRP Insert(PM_ALT_EVENT_TYPE_GRP entity) { PM_ALT_EVENT_TYPE_GRP newEntity = null; try { ArgumentValidator.CheckForNullArgument(entity, "PM_ALT_EVENT_TYPE_GRP Entity"); newEntity = _PM_ALT_EVENT_TYPE_GRPDAO.Insert(entity); } catch (Exception ex) { ExceptionPolicy.HandleException(ex, ExceptionPolicy.BusinessLogicDefaultPolicy); } return(newEntity); }
/// <summary> /// Insert /// </summary> public PM_ALT_EVENT_TYPE_GRP Insert(PM_ALT_EVENT_TYPE_GRP entity) { ArgumentValidator.CheckForNullArgument(entity, "entity"); PersistentPM_ALT_EVENT_TYPE_GRP PM_ALT_EVENT_TYPE_GRPEntity = entity as PersistentPM_ALT_EVENT_TYPE_GRP; try { Database db = GetDatabaseInstance(); DbCommand dbCommand = db.GetSqlStringCommand(PM_ALT_EVENT_TYPE_GRPDAO.SqlInsert); db.AddInParameter(dbCommand, "@NotiEventGroupID", DbType.Guid, PM_ALT_EVENT_TYPE_GRPEntity.NotiEventGroupID); db.AddInParameter(dbCommand, "@EventTypeID", DbType.Guid, PM_ALT_EVENT_TYPE_GRPEntity.EventTypeID); db.AddInParameter(dbCommand, "@NotiGroupID", DbType.Guid, PM_ALT_EVENT_TYPE_GRPEntity.NotiGroupID); int result = db.ExecuteNonQuery(dbCommand); } catch (Exception ex) { ExceptionPolicy.HandleException(ex, ExceptionPolicy.DataAccessDefaultPolicy); } return(PM_ALT_EVENT_TYPE_GRPEntity as PM_ALT_EVENT_TYPE_GRP); }
private void UpdateSome(PM_ALT_EVENT_TYPE_GRP entity, DbTransaction transaction) { ArgumentValidator.CheckForNullArgument(entity, "entity"); ArgumentValidator.CheckForNullArgument(transaction, "transaction"); PersistentPM_ALT_EVENT_TYPE_GRP PM_ALT_EVENT_TYPE_GRPEntity = entity as PersistentPM_ALT_EVENT_TYPE_GRP; StringBuilder sqlUpdateSome = new StringBuilder(); sqlUpdateSome.Append("UPDATE dbo.PM_ALT_EVENT_TYPE_GRP SET "); PropertyInfo[] propertyInfos = PM_ALT_EVENT_TYPE_GRPEntity.GetType().GetProperties(); Hashtable propertyValues = new System.Collections.Hashtable(); int columnCountForUpdate = 0; foreach (PropertyInfo propertyInfo in propertyInfos) { if (EntityMapping.ContainsProperty(propertyInfo.Name)) { object propertyValue = propertyInfo.GetValue(PM_ALT_EVENT_TYPE_GRPEntity, null); ORProperty property = EntityMapping[propertyInfo.Name]; if (!property.IsPrimaryKey) { if (!PM_ALT_EVENT_TYPE_GRPEntity.IsDefaultValue(propertyInfo.Name)) { propertyValues[propertyInfo.Name] = propertyValue; sqlUpdateSome.Append(" " + property.ColumnName + " = @" + property.ColumnName + ","); columnCountForUpdate++; } } else { propertyValues[propertyInfo.Name] = propertyValue; } } } if (columnCountForUpdate == 0) { return; } sqlUpdateSome.Remove(sqlUpdateSome.Length - 1, 1); sqlUpdateSome.Append(" WHERE 1 = 1 "); sqlUpdateSome.Append(" AND NotiEventGroupID = @NotiEventGroupID "); try { Database db = GetDatabaseInstance(); DbCommand dbCommand = db.GetSqlStringCommand(sqlUpdateSome.ToString()); foreach (DictionaryEntry de in propertyValues) { ORProperty property = EntityMapping[de.Key.ToString()]; db.AddInParameter(dbCommand, "@" + property.ColumnName, property.DatabaseType, de.Value); } int result = db.ExecuteNonQuery(dbCommand, transaction); if (result == 0) { throw new EntityNotFoundException(); } } catch (Exception ex) { ExceptionPolicy.HandleException(ex, ExceptionPolicy.DataAccessDefaultPolicy); } }
/// <summary> /// Update with transaction /// </summary> public void Update(PM_ALT_EVENT_TYPE_GRP entity, DbTransaction transaction) { Update(entity, true, transaction); }
/// <summary> /// Update /// </summary> public void Update(PM_ALT_EVENT_TYPE_GRP entity) { Update(entity, true); }