예제 #1
0
 internal Domain(Schema schema, string name, SqlValueType dataType, SqlExpression defaultValue) : base(schema, name)
 {
     this.dataType     = dataType;
     this.defaultValue = defaultValue;
     constraints       =
         new PairedNodeCollection <Domain, DomainConstraint>(this, "DomainConstraints");
 }
예제 #2
0
 public override string Translate(SqlValueType type)
 {
     // we need to explicitly specify maximum interval precision
     if (type.Type == SqlType.Interval)
     {
         return("INTERVAL DAY(6) TO SECOND(3)");
     }
     return(base.Translate(type));
 }
예제 #3
0
        public void TypeTest()
        {
            SqlValueType t1 = new SqlValueType(SqlType.Decimal, 6, 4);
            SqlValueType t2 = new SqlValueType(SqlType.Decimal, 6, 4);

            Assert.IsFalse(t1 != t2);
            Assert.IsTrue(t1 == t2);
            Assert.IsTrue(t1.Equals(t2));
        }
예제 #4
0
        public override void ReplaceWith(SqlExpression expression)
        {
            ArgumentValidator.EnsureArgumentNotNull(expression, "expression");
            ArgumentValidator.EnsureArgumentIs <SqlCast>(expression, "expression");
            var replacingExpression = (SqlCast)expression;

            Operand = replacingExpression.Operand;
            Type    = replacingExpression.Type;
        }
예제 #5
0
 private void CompareSqlValueTypes(SqlValueType t1, SqlValueType t2)
 {
     Assert.IsNotNull(t1);
     Assert.IsNotNull(t2);
     Assert.AreEqual(t1.Type, t2.Type);
     Assert.AreEqual(t1.Precision, t2.Precision);
     Assert.AreEqual(t1.Scale, t2.Scale);
     Assert.AreEqual(t1.Length, t2.Length);
 }
예제 #6
0
 public override string Translate(SqlValueType type)
 {
     // we need to explicitly specify maximum interval precision
     if (type.Type == SqlType.Interval)
     {
         return("decimal(18, 18)");
     }
     return(base.Translate(type));
 }
 /// <summary>
 /// Initializes a new instance of this class.
 /// </summary>
 /// <param name="type">Underlying data type.</param>
 /// <param name="nativeType">The native type.</param>
 /// <param name="isNullable">Indicates whether type is nullable.</param>
 public StorageTypeInfo(Type type, SqlValueType nativeType, bool isNullable)
 {
     ArgumentValidator.EnsureArgumentNotNull(type, "type");
     if (isNullable && type.IsValueType && !type.IsNullable())
     {
         ArgumentValidator.EnsureArgumentIsInRange(true, false, false, "isNullable");
     }
     Type       = type;
     IsNullable = isNullable;
     NativeType = nativeType;
 }
예제 #8
0
        /*
         * [SecuritySafeCritical]
         * public override object ReadDateTimeOffset(DbDataReader reader, int index)
         * {
         * var nativeReader = (NpgsqlDataReader)reader;
         * return (DateTimeOffset)nativeReader.GetTimeStampTZ(index);
         * }
         */

        protected virtual SqlValueType ReduceDecimalScale(SqlValueType sqlType, int newScale)
        {
            if (sqlType.Type != SqlType.Decimal)
            {
                return(sqlType);
            }
            if (!sqlType.Precision.HasValue)
            {
                return(sqlType);
            }
            return(new SqlValueType(sqlType.Type, sqlType.Precision.Value, newScale));
        }
예제 #9
0
 public BooleanExpressionConverter(StorageDriver driver)
 {
     booleanType = driver.MapValueType(typeof(bool));
 }
예제 #10
0
 /// <summary>
 /// Creates the table column.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="dataType">Column datatype.</param>
 public TableColumn CreateColumn(string name, SqlValueType dataType)
 {
     return(new TableColumn(this, name, dataType));
 }
 /// <summary>
 /// Initializes a new instance of this class.
 /// </summary>
 /// <param name="type">Underlying data type.</param>
 /// <param name="nativeType">The native type.</param>
 /// <param name="isNullable">Indicates whether type is nullable.</param>
 /// <param name="length">The length.</param>
 /// <param name="precision">The precision.</param>
 /// <param name="scale">The scale.</param>
 public StorageTypeInfo(Type type, SqlValueType nativeType, bool isNullable, int?length, int?precision, int?scale)
     : this(type, nativeType, isNullable, length)
 {
     Scale     = scale;
     Precision = precision;
 }
 /// <summary>
 /// Initializes a new instance of this class.
 /// </summary>
 /// <param name="type">Underlying data type.</param>
 /// <param name="nativeType">The native type.</param>
 /// <param name="isNullable">Indicates whether type is nullable.</param>
 /// <param name="length">The length.</param>
 public StorageTypeInfo(Type type, SqlValueType nativeType, bool isNullable, int?length)
     : this(type, nativeType, isNullable)
 {
     Length = length;
 }
예제 #13
0
 /// <summary>
 /// Creates the domain.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="dataType">Datatype.</param>
 public Domain CreateDomain(string name, SqlValueType dataType)
 {
     return(new Domain(this, name, dataType, null));
 }
예제 #14
0
 internal SqlVariable(string name, SqlValueType type)
     : base(SqlNodeType.Variable)
 {
     this.name = name;
     this.type = type;
 }
 public BooleanExpressionConverter(StorageDriver driver)
 {
     booleanType = driver.MapValueType(WellKnownTypes.Bool);
 }
예제 #16
0
 internal TableColumn(Table table, string name, SqlValueType dataType) : base(table, name)
 {
     this.dataType = dataType;
 }
예제 #17
0
 /// <summary>
 /// Creates the partition function.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="dataType">Type of the input parameter.</param>
 /// <param name="boundaryValues">The boundary values.</param>
 public PartitionFunction CreatePartitionFunction(string name, SqlValueType dataType, params string[] boundaryValues)
 {
     return(new PartitionFunction(this, name, dataType, boundaryValues));
 }
 internal PartitionFunction(Catalog catalog, string name, SqlValueType dataType,
                            params string[] boundaryValues) : base(catalog, name)
 {
     this.dataType       = dataType;
     this.boundaryValues = boundaryValues;
 }
 /// <summary>
 /// Initializes a new instance of this class.
 /// </summary>
 /// <param name="type">Underlying data type.</param>
 /// <param name="nativeType">The native type.</param>
 public StorageTypeInfo(Type type, SqlValueType nativeType)
     : this(type, nativeType, type.IsClass || type.IsNullable())
 {
 }
 /// <summary>
 /// Initializes a new instance of this class.
 /// </summary>
 /// <param name="type">Underlying data type.</param>
 /// <param name="nativeType">The native type.</param>
 /// <param name="length">The length.</param>
 public StorageTypeInfo(Type type, SqlValueType nativeType, int?length)
     : this(type, nativeType, type.IsClass || type.IsNullable(), length)
 {
 }
 /// <summary>
 /// Initializes a new instance of this class.
 /// </summary>
 /// <param name="type">Underlying data type.</param>
 /// <param name="nativeType">The native type.</param>
 /// <param name="length">The length.</param>
 /// <param name="precision">The precision.</param>
 /// <param name="scale">The scale.</param>
 public StorageTypeInfo(Type type, SqlValueType nativeType, int?length, int?precision, int?scale)
     : this(type, nativeType, type.IsClass || type.IsNullable(), length, precision, scale)
 {
 }
예제 #22
0
 internal SqlCast(SqlExpression operand, SqlValueType type)
     : base(SqlNodeType.Cast)
 {
     Operand = operand;
     Type    = type;
 }
예제 #23
0
 /// <summary>
 /// Creates the domain.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="dataType">Datatype.</param>
 /// <param name="defaultValue">The default value.</param>
 public Domain CreateDomain(string name, SqlValueType dataType, SqlExpression defaultValue)
 {
     return(new Domain(this, name, dataType, defaultValue));
 }