Esempio n. 1
0
        /// <inheritdoc />
        public override MsSqlColumnType GetCommonType(MsSqlColumnType otherType)
        {
            if (otherType is NullMsSqlColumnType)
            {
                return(this);
            }

            if (otherType is TextMsSqlColumnType)
            {
                return(otherType);
            }

            if (otherType is DateTimeMsSqlColumnType otherDateTimeType)
            {
                if (DateTimeType != otherDateTimeType.DateTimeType)
                {
                    return(new DateTimeMsSqlColumnType(DateTimeTypes.DateTime2));
                }
                else
                {
                    return(this);
                }
            }

            return(VarCharMsSqlColumnType.NVarCharMaxType);
        }
Esempio n. 2
0
        /// <inheritdoc />
        public override MsSqlColumnType GetCommonType(MsSqlColumnType otherType)
        {
            if (otherType is NullMsSqlColumnType)
            {
                return(this);
            }

            if (otherType is TextMsSqlColumnType)
            {
                return(otherType);
            }

            if (otherType is FloatingPointMsSqlColumnType otherFloatingType)
            {
                var t = FloatingType > otherFloatingType.FloatingType ? FloatingType : otherFloatingType.FloatingType;
                return(new FloatingPointMsSqlColumnType(t));
            }

            if (otherType is IntegerMsSqlColumnType)
            {
                return(DecimalMsSqlColumnType.MaxPrecisionType);
            }

            if (otherType is DecimalMsSqlColumnType)
            {
                return(DecimalMsSqlColumnType.MaxPrecisionType);
            }

            return(VarCharMsSqlColumnType.NVarCharMaxType);
        }
Esempio n. 3
0
 /// <inheritdoc />
 public override MsSqlColumnType GetCommonType(MsSqlColumnType otherType)
 {
     if (otherType is TextMsSqlColumnType otherTextMsSqlColumnType)
     {
         return(new TextMsSqlColumnType(IsUnicode || otherTextMsSqlColumnType.IsUnicode));
     }
     else if (otherType is VarCharMsSqlColumnType otherVarCharSqlColumnType)
     {
         return(new TextMsSqlColumnType(IsUnicode || otherVarCharSqlColumnType.IsUnicode));
     }
     else
     {
         return(this);
     }
 }
Esempio n. 4
0
        /// <inheritdoc />
        public override MsSqlColumnType GetCommonType(MsSqlColumnType otherType)
        {
            if (otherType is NullMsSqlColumnType)
            {
                return(this);
            }

            if (otherType is TextMsSqlColumnType)
            {
                return(otherType);
            }

            if (otherType is FloatingPointMsSqlColumnType)
            {
                return(MaxPrecisionType);
            }

            if (otherType is IntegerMsSqlColumnType)
            {
                return(MaxPrecisionType);
            }

            if (otherType is DecimalMsSqlColumnType otherDecimalMsSqlColumnType)
            {
                var maxPrecision = Math.Max(Precision, otherDecimalMsSqlColumnType.Precision);
                var maxScale     = Math.Max(Scale, otherDecimalMsSqlColumnType.Scale);
                var minScale     = Math.Min(Scale, otherDecimalMsSqlColumnType.Scale);
                var precision    = maxPrecision + (maxScale - minScale);
                if (precision > 38)
                {
                    precision = 38;
                }

                return(new DecimalMsSqlColumnType(precision, maxScale));
            }

            return(VarCharMsSqlColumnType.NVarCharMaxType);
        }
Esempio n. 5
0
        /// <inheritdoc />
        public override MsSqlColumnType GetCommonType(MsSqlColumnType otherType)
        {
            if (otherType is NullMsSqlColumnType)
            {
                return(this);
            }

            if (otherType is TextMsSqlColumnType otherTextMsSqlColumnType)
            {
                return(new TextMsSqlColumnType(IsUnicode || otherTextMsSqlColumnType.IsUnicode));
            }

            if (otherType is VarCharMsSqlColumnType otherVarCharMsSqlColumnType)
            {
                var newMaxLength = MaxLength.HasValue && otherVarCharMsSqlColumnType.MaxLength.HasValue
                    ? (int?)Math.Max(MaxLength.Value, otherVarCharMsSqlColumnType.MaxLength.Value)
                    : null;

                return(new VarCharMsSqlColumnType(IsVar || otherVarCharMsSqlColumnType.IsVar,
                                                  IsUnicode || otherVarCharMsSqlColumnType.IsUnicode, newMaxLength));
            }

            return(NVarCharMaxType);
        }
Esempio n. 6
0
        public static MsSqlTable CreateFromDatabase(DatabaseTable tableSchema)
        {
            var columns = tableSchema.Columns.Select(column =>
                                                     new SqlColumnSchema(column.Name, column.Nullable, MsSqlColumnType.Create(column.DbDataType)));

            return(new MsSqlTable(tableSchema.Name, columns, tableSchema.PrimaryKey, tableSchema.UniqueKeys));
        }
Esempio n. 7
0
 /// <inheritdoc />
 public override MsSqlColumnType GetCommonType(MsSqlColumnType otherType)
 {
     return(otherType);
 }
Esempio n. 8
0
 public abstract MsSqlColumnType GetCommonType(MsSqlColumnType otherType);