private void UpdateAll(PM_ALT_BASE entity, DbTransaction transaction)
        {
            ArgumentValidator.CheckForNullArgument(entity, "entity");
            ArgumentValidator.CheckForNullArgument(transaction, "transaction");

            PersistentPM_ALT_BASE PM_ALT_BASEEntity = entity as PersistentPM_ALT_BASE;

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

                db.AddInParameter(dbCommand, "@AlertID", DbType.Guid, PM_ALT_BASEEntity.AlertID);
                db.AddInParameter(dbCommand, "@AlertName", DbType.String, PM_ALT_BASEEntity.AlertName);
                db.AddInParameter(dbCommand, "@AlertAlias", DbType.String, PM_ALT_BASEEntity.AlertAlias);
                db.AddInParameter(dbCommand, "@SqlScript", DbType.String, PM_ALT_BASEEntity.SqlScript);
                db.AddInParameter(dbCommand, "@URL", DbType.String, PM_ALT_BASEEntity.URL);
                db.AddInParameter(dbCommand, "@AlertDesc", DbType.String, PM_ALT_BASEEntity.AlertDesc);
                db.AddInParameter(dbCommand, "@AlertContent", DbType.String, PM_ALT_BASEEntity.AlertContent);
                db.AddInParameter(dbCommand, "@Category", DbType.String, PM_ALT_BASEEntity.Category);
                db.AddInParameter(dbCommand, "@AlertType", DbType.Int32, PM_ALT_BASEEntity.AlertType);
                db.AddInParameter(dbCommand, "@Format", DbType.String, PM_ALT_BASEEntity.Format);
                db.AddInParameter(dbCommand, "@AlertObject", DbType.String, PM_ALT_BASEEntity.AlertObject);
                db.AddInParameter(dbCommand, "@PreProcedure", DbType.String, PM_ALT_BASEEntity.PreProcedure);
                db.AddInParameter(dbCommand, "@PostProcedure", DbType.String, PM_ALT_BASEEntity.PostProcedure);
                db.AddInParameter(dbCommand, "@AlertInterval", DbType.Int32, PM_ALT_BASEEntity.AlertInterval);
                db.AddInParameter(dbCommand, "@AlertTimePoints", DbType.String, PM_ALT_BASEEntity.AlertTimePoints);
                db.AddInParameter(dbCommand, "@LastAlertedTime", DbType.DateTime, PM_ALT_BASEEntity.LastAlertedTime);
                db.AddInParameter(dbCommand, "@IsActive", DbType.Boolean, PM_ALT_BASEEntity.IsActive);
                db.AddInParameter(dbCommand, "@RowDeleted", DbType.Boolean, PM_ALT_BASEEntity.RowDeleted);
                db.AddInParameter(dbCommand, "@CreatedBy", DbType.String, PM_ALT_BASEEntity.CreatedBy);
                db.AddInParameter(dbCommand, "@CreatedOn", DbType.DateTime, PM_ALT_BASEEntity.CreatedOn);
                db.AddInParameter(dbCommand, "@ModifiedBy", DbType.String, PM_ALT_BASEEntity.ModifiedBy);
                db.AddInParameter(dbCommand, "@ModifiedOn", DbType.DateTime, PM_ALT_BASEEntity.ModifiedOn);
                int result = db.ExecuteNonQuery(dbCommand, transaction);

                if (result == 0)
                {
                    throw new EntityNotFoundException();
                }
            }
            catch (Exception ex)
            {
                ExceptionPolicy.HandleException(ex, ExceptionPolicy.DataAccessDefaultPolicy);
            }
        }
        private void UpdateSome(PM_ALT_BASE entity, DbTransaction transaction)
        {
            ArgumentValidator.CheckForNullArgument(entity, "entity");
            ArgumentValidator.CheckForNullArgument(transaction, "transaction");

            PersistentPM_ALT_BASE PM_ALT_BASEEntity = entity as PersistentPM_ALT_BASE;

            StringBuilder sqlUpdateSome = new StringBuilder();

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

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

            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);
            }
        }