Ejemplo n.º 1
0
        public override SqlType GetCombinedType(SqlType other, int operation)
        {
            switch (operation)
            {
            case 0x20:
                if (!other.IsDateTimeType())
                {
                    if (other.IsIntervalType())
                    {
                        IntervalType aggregateType = (IntervalType)this.GetAggregateType(other);
                        return(GetIntervalType(aggregateType, 9L, aggregateType.Scale));
                    }
                    break;
                }
                return(other.GetCombinedType(this, operation));

            case 0x22:
                if (!other.IsNumberType())
                {
                    break;
                }
                return(GetIntervalType(this, 9L, base.Scale));

            case 0x23:
                if (!other.IsNumberType())
                {
                    break;
                }
                return(this);

            default:
                return(this.GetAggregateType(other));
            }
            throw Error.GetError(0x15ba);
        }
Ejemplo n.º 2
0
 public override SqlType GetCombinedType(SqlType other, int operation)
 {
     if ((operation - 0x20) > 1)
     {
         if ((operation - 0x29) <= 5)
         {
             int num2;
             if (base.TypeCode == other.TypeCode)
             {
                 return(this);
             }
             if (other.TypeCode == 0)
             {
                 return(this);
             }
             if (!other.IsDateTimeType())
             {
                 throw Error.GetError(0x15ba);
             }
             DateTimeType type = (DateTimeType)other;
             if ((type.StartIntervalType > base.EndIntervalType) || (base.StartIntervalType > type.EndIntervalType))
             {
                 throw Error.GetError(0x15ba);
             }
             int  scale = (base.Scale > type.Scale) ? base.Scale : type.Scale;
             bool flag  = this._withTimeZone || type._withTimeZone;
             if (((type.StartIntervalType > base.StartIntervalType) ? base.StartIntervalType : type.StartIntervalType) == 0x68)
             {
                 num2 = flag ? 0x5e : 0x5c;
             }
             else
             {
                 num2 = flag ? 0x5f : 0x5d;
             }
             return(GetDateTimeType(num2, scale));
         }
     }
     else
     {
         if (other.IsIntervalType())
         {
             if ((base.TypeCode != 0x5b) && (other.Scale > base.Scale))
             {
                 return(GetDateTimeType(base.TypeCode, other.Scale));
             }
             return(this);
         }
         if ((base.TypeCode == 0x5b) && other.IsNumberType())
         {
             return(SqlType.SqlDate);
         }
     }
     throw Error.GetError(0x15ba);
 }
Ejemplo n.º 3
0
 public static bool IsValidDatetimeRange(SqlType a, SqlType b)
 {
     if (!a.IsDateTimeType())
     {
         return(false);
     }
     if (b.IsDateTimeType())
     {
         return(((a.TypeCode != 0x5c) || (b.TypeCode != 0x5b)) && ((a.TypeCode != 0x5b) || (b.TypeCode != 0x5c)));
     }
     return(b.IsIntervalType() && ((DateTimeType)a).CanAdd((IntervalType)b));
 }
Ejemplo n.º 4
0
        public override SqlType GetAggregateType(SqlType other)
        {
            int num2;

            if (base.TypeCode == other.TypeCode)
            {
                if (base.Scale < other.Scale)
                {
                    return(other);
                }
                return(this);
            }
            if (other.TypeCode == 0)
            {
                return(this);
            }
            if (other.IsCharacterType())
            {
                return(other.GetAggregateType(this));
            }
            if (!other.IsDateTimeType())
            {
                throw Error.GetError(0x15ba);
            }
            DateTimeType type2 = (DateTimeType)other;

            if ((type2.StartIntervalType > base.EndIntervalType) || (base.StartIntervalType > type2.EndIntervalType))
            {
                throw Error.GetError(0x15ba);
            }
            int  scale = (base.Scale > type2.Scale) ? base.Scale : type2.Scale;
            bool flag  = this._withTimeZone || type2._withTimeZone;

            if (((type2.StartIntervalType > base.StartIntervalType) ? base.StartIntervalType : type2.StartIntervalType) == 0x68)
            {
                num2 = flag ? 0x5e : 0x5c;
            }
            else
            {
                num2 = flag ? 0x5f : 0x5d;
            }
            return(GetDateTimeType(num2, scale));
        }
Ejemplo n.º 5
0
 public override bool CanConvertFrom(SqlType othType)
 {
     if (othType.TypeCode == 0)
     {
         return(true);
     }
     if (othType.IsCharacterType())
     {
         return(true);
     }
     if (!othType.IsDateTimeType())
     {
         return(false);
     }
     if (othType.TypeCode == 0x5b)
     {
         return(base.TypeCode != 0x5c);
     }
     return((othType.TypeCode != 0x5c) || (base.TypeCode != 0x5b));
 }