Пример #1
0
        internal static MySqlParameter GetMySqlParameter(this DmColumn column)
        {
            MySqlDbMetadata mySqlDbMetadata = new MySqlDbMetadata();
            MySqlParameter  sqlParameter    = new MySqlParameter();

            sqlParameter.ParameterName = $"in{column.ColumnName}";
            sqlParameter.DbType        = column.DbType;
            sqlParameter.IsNullable    = column.AllowDBNull;

            (byte precision, byte scale) = mySqlDbMetadata.TryGetOwnerPrecisionAndScale(column.OriginalDbType, column.DbType, false, false, column.Precision, column.Scale, column.Table.OriginalProvider, MySqlSyncProvider.ProviderType);

            if ((sqlParameter.DbType == DbType.Decimal || sqlParameter.DbType == DbType.Double ||
                 sqlParameter.DbType == DbType.Single || sqlParameter.DbType == DbType.VarNumeric) && precision > 0)
            {
                sqlParameter.Precision = precision;
                if (scale > 0)
                {
                    sqlParameter.Scale = scale;
                }
            }
            else if (column.MaxLength > 0)
            {
                sqlParameter.Size = (int)column.MaxLength;
            }
            else if (sqlParameter.DbType == DbType.Guid)
            {
                sqlParameter.Size = 36;
            }
            else
            {
                sqlParameter.Size = -1;
            }

            return(sqlParameter);
        }
        internal MySqlParameter GetMySqlParameter(SyncColumn column)
        {
            var mySqlDbMetadata = new MySqlDbMetadata();

            var parameterName = ParserName.Parse(column, "`").Unquoted().Normalized().ToString();

            var sqlParameter = new MySqlParameter
            {
                ParameterName = $"{MySqlBuilderProcedure.MYSQL_PREFIX_PARAMETER}{parameterName}",
                DbType        = column.GetDbType(),
                IsNullable    = column.AllowDBNull
            };

#if MARIADB
            (byte precision, byte scale) = mySqlDbMetadata.TryGetOwnerPrecisionAndScale(column.OriginalDbType, column.GetDbType(), false, false, column.MaxLength, column.Precision, column.Scale, this.tableDescription.OriginalProvider, MariaDB.MariaDBSyncProvider.ProviderType);
#elif MYSQL
            (byte precision, byte scale) = mySqlDbMetadata.TryGetOwnerPrecisionAndScale(column.OriginalDbType, column.GetDbType(), false, false, column.MaxLength, column.Precision, column.Scale, this.tableDescription.OriginalProvider, MySqlSyncProvider.ProviderType);
#endif

            if ((sqlParameter.DbType == DbType.Decimal || sqlParameter.DbType == DbType.Double ||
                 sqlParameter.DbType == DbType.Single || sqlParameter.DbType == DbType.VarNumeric) && precision > 0)
            {
                sqlParameter.Precision = precision;
                if (scale > 0)
                {
                    sqlParameter.Scale = scale;
                }
            }
            else if (column.MaxLength > 0)
            {
                sqlParameter.Size = (int)column.MaxLength;
            }
            else if (sqlParameter.DbType == DbType.Guid)
            {
                sqlParameter.Size = 36;
            }
            else
            {
                sqlParameter.Size = -1;
            }

            return(sqlParameter);
        }
Пример #3
0
        internal static MySqlParameter GetMySqlParameter(this DmColumn column)
        {
            MySqlDbMetadata mySqlDbMetadata = new MySqlDbMetadata();

            var parameterName = ParserName.Parse(column).Unquoted().Normalized().ToString();

            MySqlParameter sqlParameter = new MySqlParameter
            {
                ParameterName = $"{MySqlBuilderProcedure.MYSQL_PREFIX_PARAMETER}{parameterName}",
                DbType        = column.DbType,
                IsNullable    = column.AllowDBNull
            };

            (byte precision, byte scale) = mySqlDbMetadata.TryGetOwnerPrecisionAndScale(column.OriginalDbType, column.DbType, false, false, column.MaxLength, column.Precision, column.Scale, column.Table.OriginalProvider, MySqlSyncProvider.ProviderType);

            if ((sqlParameter.DbType == DbType.Decimal || sqlParameter.DbType == DbType.Double ||
                 sqlParameter.DbType == DbType.Single || sqlParameter.DbType == DbType.VarNumeric) && precision > 0)
            {
                sqlParameter.Precision = precision;
                if (scale > 0)
                {
                    sqlParameter.Scale = scale;
                }
            }
            else if (column.MaxLength > 0)
            {
                sqlParameter.Size = (int)column.MaxLength;
            }
            else if (sqlParameter.DbType == DbType.Guid)
            {
                sqlParameter.Size = 36;
            }
            else
            {
                sqlParameter.Size = -1;
            }

            return(sqlParameter);
        }