public override DataTypeCollection GetDataTypesInfo() { const DataTypeFeatures common = DataTypeFeatures.Default | DataTypeFeatures.Nullable | DataTypeFeatures.NonKeyIndexing | DataTypeFeatures.Grouping | DataTypeFeatures.Ordering | DataTypeFeatures.Multiple; const DataTypeFeatures index = DataTypeFeatures.Indexing | DataTypeFeatures.Clustering | DataTypeFeatures.FillFactor | DataTypeFeatures.KeyConstraint; var types = new DataTypeCollection(); types.Decimal = DataTypeInfo.Fractional(SqlType.Decimal, common | index, ValueRange.Decimal, 38, "number"); types.Float = DataTypeInfo.Range(SqlType.Float, common | index, ValueRange.Float, "real"); types.Double = DataTypeInfo.Range(SqlType.Double, common | index, ValueRange.Double, "double precision", "float"); types.DateTime = DataTypeInfo.Range(SqlType.DateTime, common | index, ValueRange.DateTime, "timestamp"); types.DateTimeOffset = DataTypeInfo.Range(SqlType.DateTimeOffset, common | index, ValueRange.DateTimeOffset, "TIMESTAMP WITH TIME ZONE"); types.Interval = DataTypeInfo.Range(SqlType.Interval, common | index, ValueRange.TimeSpan, "interval day to second"); types.Char = DataTypeInfo.Stream(SqlType.Char, common | index | DataTypeFeatures.ZeroLengthValueIsNull, 2000, "nchar"); types.VarChar = DataTypeInfo.Stream(SqlType.VarChar, common | index | DataTypeFeatures.ZeroLengthValueIsNull, 2000, "nvarchar2"); types.VarCharMax = DataTypeInfo.Regular(SqlType.VarCharMax, common, "nclob"); types.VarBinaryMax = DataTypeInfo.Regular(SqlType.VarBinaryMax, common, "blob"); return(types); }
/// <summary> /// Creates a regular <see cref="DataTypeInfo"/> /// </summary> public static DataTypeInfo Regular( SqlType sqlType, DataTypeFeatures features, params string[] nativeTypes) { return(new DataTypeInfo { Type = sqlType, Features = features, NativeTypes = nativeTypes.ToArraySafely(), }); }
/// <inheritdoc/> public override DataTypeCollection GetDataTypesInfo() { var types = new DataTypeCollection(); DataTypeFeatures common = DataTypeFeatures.Default | DataTypeFeatures.Nullable | DataTypeFeatures.NonKeyIndexing | DataTypeFeatures.Grouping | DataTypeFeatures.Ordering | DataTypeFeatures.Multiple; DataTypeFeatures index = DataTypeFeatures.Indexing | DataTypeFeatures.KeyConstraint; DataTypeFeatures identity = DataTypeFeatures.Identity; types.Boolean = DataTypeInfo.Range(SqlType.Boolean, common | index, ValueRange.Bool, "boolean"); types.Int8 = DataTypeInfo.Range(SqlType.Int8, common | index | identity, ValueRange.Byte, "tinyint"); types.Int16 = DataTypeInfo.Range(SqlType.Int16, common | index | identity, ValueRange.Int16, "smallint"); types.Int32 = DataTypeInfo.Range(SqlType.Int32, common | index | identity, ValueRange.Int32, "int"); types.Int64 = DataTypeInfo.Range(SqlType.Int64, common | index | identity, ValueRange.Int64, "bigint"); types.Decimal = DataTypeInfo.Fractional(SqlType.Decimal, common | index, ValueRange.Decimal, 38, "decimal", "numeric", "year"); types.Float = DataTypeInfo.Range(SqlType.Float, common | index, ValueRange.Float, "float"); types.Double = DataTypeInfo.Range(SqlType.Double, common | index, ValueRange.Double, "double precision"); types.DateTime = DataTypeInfo.Range(SqlType.DateTime, common | index, new ValueRange <DateTime>(new DateTime(1000, 1, 1), new DateTime(9999, 12, 31)), "datetime", "time"); types.Char = DataTypeInfo.Stream(SqlType.Char, common | index, 255, "char"); types.VarChar = DataTypeInfo.Stream(SqlType.VarChar, common | index, 4000, "varchar"); types.VarCharMax = DataTypeInfo.Regular(SqlType.VarCharMax, common, "longtext"); types.Binary = DataTypeInfo.Stream(SqlType.Binary, common | index, 255, "binary"); types.VarBinary = DataTypeInfo.Stream(SqlType.VarBinary, common | index, 4000, "varbinary"); types.VarBinaryMax = DataTypeInfo.Regular(SqlType.VarBinaryMax, common, "longblob"); //types.Guid = DataTypeInfo.Regular(SqlType.Guid, common | index, "uuid()"); return(types); }
/// <summary> /// Ranges a range <see cref="DataTypeInfo"/>. /// </summary> public static DataTypeInfo Range( SqlType sqlType, DataTypeFeatures features, ValueRange valueRange, params string[] nativeTypes) { ArgumentValidator.EnsureArgumentNotNull(valueRange, "valueRange"); return(new DataTypeInfo { Type = sqlType, Features = features, ValueRange = valueRange, NativeTypes = nativeTypes.ToArraySafely(), }); }
/// <summary> /// Creates a stream <see cref="DataTypeInfo"/>. /// </summary> public static DataTypeInfo Stream( SqlType sqlType, DataTypeFeatures features, int maxLength, params string[] nativeTypes) { ArgumentValidator.EnsureArgumentIsGreaterThan(maxLength, 0, "maxLength"); return(new DataTypeInfo { Type = sqlType, Features = features, MaxLength = maxLength, NativeTypes = nativeTypes.ToArraySafely(), }); }
/// <summary> /// Creates a fractional <see cref="DataTypeInfo"/>. /// </summary> public static DataTypeInfo Fractional( SqlType sqlType, DataTypeFeatures features, ValueRange valueRange, int maxPrecision, params string[] nativeTypes) { ArgumentValidator.EnsureArgumentNotNull(valueRange, "valueRange"); ArgumentValidator.EnsureArgumentIsGreaterThan(maxPrecision, 0, "maxPrecision"); return(new DataTypeInfo { Type = sqlType, Features = features, ValueRange = valueRange, MaxPrecision = maxPrecision, NativeTypes = nativeTypes.ToArraySafely(), }); }
/// <summary> /// Determines whether the specified active features is supported. /// </summary> public static bool Supports(this DataTypeFeatures available, DataTypeFeatures required) { return((available & required) == required); }