예제 #1
0
        private void UpdateAll(PM_ALT_NOTI_GROUP_DETAIL entity, DbTransaction transaction)
        {
            ArgumentValidator.CheckForNullArgument(entity, "entity");
            ArgumentValidator.CheckForNullArgument(transaction, "transaction");

            PersistentPM_ALT_NOTI_GROUP_DETAIL PM_ALT_NOTI_GROUP_DETAILEntity = entity as PersistentPM_ALT_NOTI_GROUP_DETAIL;

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

                db.AddInParameter(dbCommand, "@NotiGroupDetailID", DbType.Guid, PM_ALT_NOTI_GROUP_DETAILEntity.NotiGroupDetailID);
                db.AddInParameter(dbCommand, "@NotiGroupID", DbType.Guid, PM_ALT_NOTI_GROUP_DETAILEntity.NotiGroupID);
                db.AddInParameter(dbCommand, "@SubGroupID", DbType.Guid, PM_ALT_NOTI_GROUP_DETAILEntity.SubGroupID);
                db.AddInParameter(dbCommand, "@MemberID", DbType.String, PM_ALT_NOTI_GROUP_DETAILEntity.MemberID);
                db.AddInParameter(dbCommand, "@RowDeleted", DbType.Boolean, PM_ALT_NOTI_GROUP_DETAILEntity.RowDeleted);
                int result = db.ExecuteNonQuery(dbCommand, transaction);

                if (result == 0)
                {
                    throw new EntityNotFoundException();
                }
            }
            catch (Exception ex)
            {
                ExceptionPolicy.HandleException(ex, ExceptionPolicy.DataAccessDefaultPolicy);
            }
        }
예제 #2
0
        /// <summary>
        /// Insert
        /// </summary>
        public PM_ALT_NOTI_GROUP_DETAIL Insert(PM_ALT_NOTI_GROUP_DETAIL entity)
        {
            ArgumentValidator.CheckForNullArgument(entity, "entity");
            PersistentPM_ALT_NOTI_GROUP_DETAIL PM_ALT_NOTI_GROUP_DETAILEntity = entity as PersistentPM_ALT_NOTI_GROUP_DETAIL;

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

                db.AddInParameter(dbCommand, "@NotiGroupDetailID", DbType.Guid, PM_ALT_NOTI_GROUP_DETAILEntity.NotiGroupDetailID);
                db.AddInParameter(dbCommand, "@NotiGroupID", DbType.Guid, PM_ALT_NOTI_GROUP_DETAILEntity.NotiGroupID);
                db.AddInParameter(dbCommand, "@SubGroupID", DbType.Guid, PM_ALT_NOTI_GROUP_DETAILEntity.SubGroupID);
                db.AddInParameter(dbCommand, "@MemberID", DbType.String, PM_ALT_NOTI_GROUP_DETAILEntity.MemberID);
                db.AddInParameter(dbCommand, "@RowDeleted", DbType.Boolean, PM_ALT_NOTI_GROUP_DETAILEntity.RowDeleted);

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

            return(PM_ALT_NOTI_GROUP_DETAILEntity as PM_ALT_NOTI_GROUP_DETAIL);
        }
예제 #3
0
        private void UpdateSome(PM_ALT_NOTI_GROUP_DETAIL entity, DbTransaction transaction)
        {
            ArgumentValidator.CheckForNullArgument(entity, "entity");
            ArgumentValidator.CheckForNullArgument(transaction, "transaction");

            PersistentPM_ALT_NOTI_GROUP_DETAIL PM_ALT_NOTI_GROUP_DETAILEntity = entity as PersistentPM_ALT_NOTI_GROUP_DETAIL;

            StringBuilder sqlUpdateSome = new StringBuilder();

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

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

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