Example #1
0
        /// <summary>
        /// Get with transaction
        /// </summary>
        public PM_ALT_SCALE Get(object entityId, DbTransaction transaction)
        {
            ArgumentValidator.CheckForNullArgument(entityId, "entityId");
            ArgumentValidator.CheckForNullArgument(transaction, "transaction");

            PM_ALT_SCALE PM_ALT_SCALEEntity = null;

            try
            {
                Database  db        = GetDatabaseInstance();
                DbCommand dbCommand = db.GetSqlStringCommand(PM_ALT_SCALEDAO.SqlGet);

                db.AddInParameter(dbCommand, "@ScalePK", DbType.Int64, entityId);
                using (IDataReader dataReader = db.ExecuteReader(dbCommand, transaction))
                {
                    if (dataReader.Read())
                    {
                        PM_ALT_SCALEEntity = ReadEntity(dataReader);
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionPolicy.HandleException(ex, ExceptionPolicy.DataAccessDefaultPolicy);
            }

            return(PM_ALT_SCALEEntity);
        }
Example #2
0
        private void UpdateAll(PM_ALT_SCALE entity, DbTransaction transaction)
        {
            ArgumentValidator.CheckForNullArgument(entity, "entity");
            ArgumentValidator.CheckForNullArgument(transaction, "transaction");

            PersistentPM_ALT_SCALE PM_ALT_SCALEEntity = entity as PersistentPM_ALT_SCALE;

            try
            {
                Database  db        = GetDatabaseInstance();
                DbCommand dbCommand = db.GetSqlStringCommand(PM_ALT_SCALEDAO.SqlUpdate);

                db.AddInParameter(dbCommand, "@ScalePK", DbType.Int64, PM_ALT_SCALEEntity.ScalePK);
                db.AddInParameter(dbCommand, "@CriterionID", DbType.Guid, PM_ALT_SCALEEntity.CriterionID);
                db.AddInParameter(dbCommand, "@Scales", DbType.String, PM_ALT_SCALEEntity.Scales);
                db.AddInParameter(dbCommand, "@ScaledValue", DbType.String, PM_ALT_SCALEEntity.ScaledValue);
                db.AddInParameter(dbCommand, "@RowDeleted", DbType.Boolean, PM_ALT_SCALEEntity.RowDeleted);
                db.AddInParameter(dbCommand, "@CreatedBy", DbType.String, PM_ALT_SCALEEntity.CreatedBy);
                db.AddInParameter(dbCommand, "@CreatedOn", DbType.DateTime, PM_ALT_SCALEEntity.CreatedOn);
                db.AddInParameter(dbCommand, "@ModifiedBy", DbType.String, PM_ALT_SCALEEntity.ModifiedBy);
                db.AddInParameter(dbCommand, "@ModifiedOn", DbType.DateTime, PM_ALT_SCALEEntity.ModifiedOn);
                int result = db.ExecuteNonQuery(dbCommand, transaction);

                if (result == 0)
                {
                    throw new EntityNotFoundException();
                }
            }
            catch (Exception ex)
            {
                ExceptionPolicy.HandleException(ex, ExceptionPolicy.DataAccessDefaultPolicy);
            }
        }
Example #3
0
        /// <summary>
        /// Insert
        /// </summary>
        public PM_ALT_SCALE Insert(PM_ALT_SCALE entity)
        {
            ArgumentValidator.CheckForNullArgument(entity, "entity");
            PersistentPM_ALT_SCALE PM_ALT_SCALEEntity = entity as PersistentPM_ALT_SCALE;

            try
            {
                Database  db        = GetDatabaseInstance();
                DbCommand dbCommand = db.GetSqlStringCommand(PM_ALT_SCALEDAO.SqlInsert);

                db.AddInParameter(dbCommand, "@CriterionID", DbType.Guid, PM_ALT_SCALEEntity.CriterionID);
                db.AddInParameter(dbCommand, "@Scales", DbType.String, PM_ALT_SCALEEntity.Scales);
                db.AddInParameter(dbCommand, "@ScaledValue", DbType.String, PM_ALT_SCALEEntity.ScaledValue);
                db.AddInParameter(dbCommand, "@RowDeleted", DbType.Boolean, PM_ALT_SCALEEntity.RowDeleted);
                db.AddInParameter(dbCommand, "@CreatedBy", DbType.String, PM_ALT_SCALEEntity.CreatedBy);
                db.AddInParameter(dbCommand, "@CreatedOn", DbType.DateTime, PM_ALT_SCALEEntity.CreatedOn);
                db.AddInParameter(dbCommand, "@ModifiedBy", DbType.String, PM_ALT_SCALEEntity.ModifiedBy);
                db.AddInParameter(dbCommand, "@ModifiedOn", DbType.DateTime, PM_ALT_SCALEEntity.ModifiedOn);

                int result = db.ExecuteNonQuery(dbCommand);
            }
            catch (Exception ex)
            {
                ExceptionPolicy.HandleException(ex, ExceptionPolicy.DataAccessDefaultPolicy);
            }

            return(PM_ALT_SCALEEntity as PM_ALT_SCALE);
        }
Example #4
0
 public void Update(PM_ALT_SCALE entity, bool updateAll, DbTransaction transaction)
 {
     if (!updateAll)
     {
         UpdateSome(entity, transaction);
     }
     else
     {
         UpdateAll(entity, transaction);
     }
 }
Example #5
0
 public void Update(PM_ALT_SCALE entity, bool updateAll)
 {
     if (!updateAll)
     {
         UpdateSome(entity);
     }
     else
     {
         UpdateAll(entity);
     }
 }
        public void UpdateSome(PM_ALT_SCALE entity)
        {
            try
            {
                ArgumentValidator.CheckForNullArgument(entity, "PM_ALT_SCALE Entity");

                _PM_ALT_SCALEDAO.Update(entity, false);
            }
            catch (Exception ex)
            {
                ExceptionPolicy.HandleException(ex, ExceptionPolicy.BusinessLogicDefaultPolicy);
            }
        }
        public PM_ALT_SCALE Insert(PM_ALT_SCALE entity)
        {
            PM_ALT_SCALE newEntity = null;

            try
            {
                ArgumentValidator.CheckForNullArgument(entity, "PM_ALT_SCALE Entity");

                newEntity = _PM_ALT_SCALEDAO.Insert(entity);
            }
            catch (Exception ex)
            {
                ExceptionPolicy.HandleException(ex, ExceptionPolicy.BusinessLogicDefaultPolicy);
            }

            return(newEntity);
        }
        public PM_ALT_SCALE GetEntity(Int64 entityPK)
        {
            PM_ALT_SCALE entity = null;

            try
            {
                ArgumentValidator.CheckForNullArgument(entityPK, "PM_ALT_SCALE Int64");

                entity = _PM_ALT_SCALEDAO.Get(entityPK);
            }
            catch (Exception ex)
            {
                ExceptionPolicy.HandleException(ex, ExceptionPolicy.BusinessLogicDefaultPolicy);
            }

            return(entity);
        }
Example #9
0
        private static PM_ALT_SCALE ReadEntity(IDataReader dataReader)
        {
            PM_ALT_SCALE PM_ALT_SCALEEntity = new PM_ALT_SCALE();
            object       value;


            value = dataReader["ScalePK"];
            if (value != DBNull.Value)
            {
                PM_ALT_SCALEEntity.ScalePK = (Int64?)value;
            }

            value = dataReader["CriterionID"];
            if (value != DBNull.Value)
            {
                PM_ALT_SCALEEntity.CriterionID = (Guid?)value;
            }

            value = dataReader["Scales"];
            if (value != DBNull.Value)
            {
                PM_ALT_SCALEEntity.Scales = (String)value;
            }

            value = dataReader["ScaledValue"];
            if (value != DBNull.Value)
            {
                PM_ALT_SCALEEntity.ScaledValue = (String)value;
            }

            value = dataReader["RowDeleted"];
            if (value != DBNull.Value)
            {
                PM_ALT_SCALEEntity.RowDeleted = (Boolean?)value;
            }

            value = dataReader["CreatedBy"];
            if (value != DBNull.Value)
            {
                PM_ALT_SCALEEntity.CreatedBy = (String)value;
            }

            value = dataReader["CreatedOn"];
            if (value != DBNull.Value)
            {
                PM_ALT_SCALEEntity.CreatedOn = (DateTime?)value;
            }

            value = dataReader["ModifiedBy"];
            if (value != DBNull.Value)
            {
                PM_ALT_SCALEEntity.ModifiedBy = (String)value;
            }

            value = dataReader["ModifiedOn"];
            if (value != DBNull.Value)
            {
                PM_ALT_SCALEEntity.ModifiedOn = (DateTime?)value;
            }

            return(PM_ALT_SCALEEntity);
        }
Example #10
0
        private void UpdateSome(PM_ALT_SCALE entity, DbTransaction transaction)
        {
            ArgumentValidator.CheckForNullArgument(entity, "entity");
            ArgumentValidator.CheckForNullArgument(transaction, "transaction");

            PersistentPM_ALT_SCALE PM_ALT_SCALEEntity = entity as PersistentPM_ALT_SCALE;

            StringBuilder sqlUpdateSome = new StringBuilder();

            sqlUpdateSome.Append("UPDATE dbo.PM_ALT_SCALE SET ");

            PropertyInfo[] propertyInfos        = PM_ALT_SCALEEntity.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_SCALEEntity, null);
                    ORProperty property      = EntityMapping[propertyInfo.Name];
                    if (!property.IsPrimaryKey)
                    {
                        if (!PM_ALT_SCALEEntity.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 ScalePK = @ScalePK ");

            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);
            }
        }
Example #11
0
        /// <summary>
        /// Update with transaction
        /// </summary>

        public void Update(PM_ALT_SCALE entity, DbTransaction transaction)
        {
            Update(entity, true, transaction);
        }
Example #12
0
        /// <summary>
        /// Update
        /// </summary>

        public void Update(PM_ALT_SCALE entity)
        {
            Update(entity, true);
        }