示例#1
0
        public override SqlType Wider(SqlType otherType)
        {
            var t1SqlType = TypeCode;
            var t2SqlType = otherType.TypeCode;

            if (t1SqlType == SqlTypeCode.Decimal)
            {
                return(this);
            }
            if (t2SqlType == SqlTypeCode.Decimal)
            {
                return(otherType);
            }
            if (t1SqlType == SqlTypeCode.Numeric)
            {
                return(this);
            }
            if (t2SqlType == SqlTypeCode.Numeric)
            {
                return(otherType);
            }

            if (t1SqlType == SqlTypeCode.Bit)
            {
                return(otherType);                // It can't be any smaller than a Bit
            }
            if (t2SqlType == SqlTypeCode.Bit)
            {
                return(this);
            }

            int t1IntSize = GetIntSize(t1SqlType);
            int t2IntSize = GetIntSize(t2SqlType);

            if (t1IntSize > 0 && t2IntSize > 0)
            {
                // Both are int types, use the largest size
                return((t1IntSize > t2IntSize) ? this : otherType);
            }

            int t1FloatSize = GetFloatSize(t1SqlType);
            int t2FloatSize = GetFloatSize(t2SqlType);

            if (t1FloatSize > 0 && t2FloatSize > 0)
            {
                // Both are floating types, use the largest size
                return((t1FloatSize > t2FloatSize) ? this : otherType);
            }

            if (t1FloatSize > t2IntSize)
            {
                return(this);
            }
            if (t2FloatSize > t1IntSize)
            {
                return(otherType);
            }
            if (t1IntSize >= t2FloatSize || t2IntSize >= t1FloatSize)
            {
                // Must be a long (8 bytes) and a real (4 bytes), widen to a double
                return(new SqlNumericType(SqlTypeCode.Double, 16, -1));
            }

            // NOTREACHED - can't get here, the last three if statements cover
            // all possibilities.
            throw new InvalidOperationException("Widest type error.");
        }
 private ISqlValue ToString(SqlString value, SqlType destType)
 {
     return(destType.NormalizeValue(value));
 }
示例#3
0
 public override bool IsComparable(SqlType type)
 {
     return(type is SqlNumericType);
 }
示例#4
0
 public override bool IsComparable(SqlType type)
 {
     return(false);
 }
示例#5
0
 public override bool CanCastTo(ISqlValue value, SqlType destType)
 {
     return(false);
 }
示例#6
0
 public override bool IsComparable(SqlType type)
 {
     return(type is SqlDateTimeType);
 }
示例#7
0
 public override bool CanCastTo(ISqlValue value, SqlType destType)
 {
     return(destType is SqlCharacterType ||
            destType is SqlDateTimeType ||
            destType is SqlNumericType);
 }
 public override bool CanCastTo(ISqlValue value, SqlType destType)
 {
     return(destType is SqlCharacterType || destType is SqlBinaryType);
 }
示例#9
0
 public override bool IsComparable(SqlType type)
 {
     return(type is SqlBooleanType);
 }
示例#10
0
 public override bool Equals(SqlType other)
 {
     return(other is SqlBooleanType);
 }