Exemplo n.º 1
0
 public NodaTimeSqlServerTypeMappingSource(TypeMappingSourceDependencies dependencies, RelationalTypeMappingSourceDependencies relationalDependencies)
     : base(dependencies, relationalDependencies)
 {
 }
Exemplo n.º 2
0
        public NpgsqlTypeMappingSource([NotNull] TypeMappingSourceDependencies dependencies,
                                       [NotNull] RelationalTypeMappingSourceDependencies relationalDependencies,
                                       [NotNull] ISqlGenerationHelper sqlGenerationHelper,
                                       [CanBeNull] INpgsqlOptions npgsqlOptions = null)
            : base(dependencies, relationalDependencies)
        {
            _sqlGenerationHelper = Check.NotNull(sqlGenerationHelper, nameof(sqlGenerationHelper));

            // Initialize some mappings which depend on other mappings
            _int4range = new NpgsqlRangeTypeMapping("int4range", typeof(NpgsqlRange <int>), _int4, sqlGenerationHelper);
            _int8range = new NpgsqlRangeTypeMapping("int8range", typeof(NpgsqlRange <long>), _int8, sqlGenerationHelper);
            _numrange  = new NpgsqlRangeTypeMapping("numrange", typeof(NpgsqlRange <decimal>), _numeric, sqlGenerationHelper);
            _tsrange   = new NpgsqlRangeTypeMapping("tsrange", typeof(NpgsqlRange <DateTime>), _timestamp, sqlGenerationHelper);
            _tstzrange = new NpgsqlRangeTypeMapping("tstzrange", typeof(NpgsqlRange <DateTime>), _timestamptz, sqlGenerationHelper);
            _daterange = new NpgsqlRangeTypeMapping("daterange", typeof(NpgsqlRange <DateTime>), _timestamptz, sqlGenerationHelper);

            // Note that PostgreSQL has aliases to some built-in type name aliases (e.g. int4 for integer),
            // these are mapped as well.
            // https://www.postgresql.org/docs/current/static/datatype.html#DATATYPE-TABLE
            var storeTypeMappings = new Dictionary <string, RelationalTypeMapping[]>(StringComparer.OrdinalIgnoreCase)
            {
                { "boolean", new[] { _bool } },
                { "bool", new[] { _bool } },
                { "bytea", new[] { _bytea } },
                { "real", new[] { _float4 } },
                { "float4", new[] { _float4 } },
                { "double precision", new[] { _float8 } },
                { "float8", new[] { _float8 } },
                { "numeric", new[] { _numeric } },
                { "decimal", new[] { _numeric } },
                { "money", new[] { _money } },
                { "uuid", new[] { _uuid } },
                { "smallint", new RelationalTypeMapping[] { _int2, _int2Byte } },
                { "int2", new RelationalTypeMapping[] { _int2, _int2Byte } },
                { "integer", new[] { _int4 } },
                { "int", new[] { _int4 } },
                { "int4", new[] { _int4 } },
                { "bigint", new[] { _int8 } },
                { "int8", new[] { _int8 } },
                { "text", new[] { _text } },
                { "jsonb", new RelationalTypeMapping[] { _jsonbString, _jsonbDocument, _jsonbElement } },
                { "json", new RelationalTypeMapping[] { _jsonString, _jsonDocument, _jsonElement } },
                { "xml", new[] { _xml } },
                { "citext", new[] { _citext } },
                { "character varying", new[] { _varchar } },
                { "varchar", new[] { _varchar } },
                { "character", new[] { _char } },
                { "char", new[] { _char } },
                { "char(1)", new RelationalTypeMapping[] { _singleChar, _stringAsSingleChar } },
                { "character(1)", new RelationalTypeMapping[] { _singleChar, _stringAsSingleChar } },
                { "date", new[] { _date } },
                { "timestamp without time zone", new[] { _timestamp } },
                { "timestamp", new[] { _timestamp } },
                { "timestamp with time zone", new[] { _timestamptz, _timestamptzDto } },
                { "timestamptz", new[] { _timestamptz, _timestamptzDto } },
                { "interval", new[] { _interval } },
                { "time without time zone", new[] { _time } },
                { "time", new[] { _time } },
                { "time with time zone", new[] { _timetz } },
                { "timetz", new[] { _timetz } },
                { "macaddr", new[] { _macaddr } },
                { "macaddr8", new[] { _macaddr8 } },
                { "inet", new[] { _inet } },
                { "cidr", new[] { _cidr } },
                { "bit", new[] { _bit } },
                { "bit varying", new[] { _varbit } },
                { "varbit", new[] { _varbit } },
                { "hstore", new[] { _hstore } },
                { "point", new[] { _point } },
                { "box", new[] { _box } },
                { "line", new[] { _line } },
                { "lseg", new[] { _lseg } },
                { "path", new[] { _path } },
                { "polygon", new[] { _polygon } },
                { "circle", new[] { _circle } },
                { "xid", new[] { _xid } },
                { "oid", new[] { _oid } },
                { "cid", new[] { _cid } },
                { "regtype", new[] { _regtype } },
                { "lo", new[] { _lo } },
                { "tid", new[] { _tid } },

                { "int4range", new[] { _int4range } },
                { "int8range", new[] { _int8range } },
                { "numrange", new[] { _numrange } },
                { "tsrange", new[] { _tsrange } },
                { "tstzrange", new[] { _tstzrange } },
                { "daterange", new[] { _daterange } },

                { "tsquery", new[] { _tsquery } },
                { "tsvector", new[] { _tsvector } },
                { "regconfig", new[] { _regconfig } }
            };

            var clrTypeMappings = new Dictionary <Type, RelationalTypeMapping>
            {
                { typeof(bool), _bool },
        /// <summary>
        /// 实例化类型映射源
        /// </summary>
        /// <param name="dependencies">类型映射源</param>
        /// <param name="relationalDependencies">关系类型映射源</param>
        /// <param name="oracleOptions">选项</param>
        /// <param name="logger">日志</param>
        public OracleTypeMappingSource(
            [NotNull] TypeMappingSourceDependencies dependencies,
            [NotNull] RelationalTypeMappingSourceDependencies relationalDependencies,
            [NotNull] IOracleOptions oracleOptions,
            IDiagnosticsLogger <DbLoggerCategory.Model> logger = null)
            : base(dependencies, relationalDependencies)
        {
            m_oracleLogger = logger;
            if (oracleOptions != null && oracleOptions.OracleSQLCompatibility != null)
            {
                _oracleSQLCompatibility = oracleOptions.OracleSQLCompatibility;
            }

            string oracleSQLCompatibility = _oracleSQLCompatibility;

            _xml = new OracleStringTypeMapping("XML", null, oracleSQLCompatibility, unicode: true);
            _fixedLengthUnicodeString = new OracleStringTypeMapping("NCHAR", oracleSQLCompatibility: _oracleSQLCompatibility, dbType: DbType.String, unicode: true, size: null, fixedLength: true);

            oracleSQLCompatibility       = _oracleSQLCompatibility;
            _variableLengthUnicodeString = new OracleStringTypeMapping("NVARCHAR2", null, oracleSQLCompatibility, unicode: true);
            _fixedLengthAnsiString       = new OracleStringTypeMapping("CHAR", oracleSQLCompatibility: _oracleSQLCompatibility, dbType: DbType.AnsiString, unicode: false, size: null, fixedLength: true);
            _variableLengthAnsiString    = new OracleStringTypeMapping("VARCHAR2", oracleSQLCompatibility: _oracleSQLCompatibility, dbType: DbType.AnsiString);
            _timeYTM = new OracleStringTypeMapping("INTERVAL YEAR(2) TO MONTH", oracleSQLCompatibility: _oracleSQLCompatibility, dbType: DbType.String);

            oracleSQLCompatibility = _oracleSQLCompatibility;
            _urowID = new OracleStringTypeMapping("UROWID", null, oracleSQLCompatibility);

            if (Check.IsTraceEnabled(m_oracleLogger?.Logger))
            {
                Trace <DbLoggerCategory.Model> .Write(m_oracleLogger, LogLevel.Trace, OracleTraceTag.Entry, OracleTraceClassName.OracleTypeMappingSource, OracleTraceFuncName.ctor);
            }

            // 通用语言运行时类型映射表,通用语言运行时(CLR)支持的数据类型与数据库支持的类型之间的映射
            _clrTypeMappings = new Dictionary <Type, RelationalTypeMapping>
            {
                { typeof(bool), _bool },
                { typeof(sbyte), _sbyte },
                { typeof(byte), _byte },
                { typeof(short), _short },
                { typeof(ushort), _ushort },
                { typeof(int), _int },
                { typeof(uint), _uint },
                { typeof(long), _long },
                { typeof(ulong), _ulong },
                { typeof(float), _float },
                { typeof(double), _double },
                { typeof(decimal), _decimal },
                { typeof(DateTime), _datetime },
                { typeof(DateTimeOffset), _datetimeoffset3 },
                { typeof(TimeSpan), _time },
                { typeof(Guid), _guid }
            };

            // 存储类型映射表, 模型上的类型名称注解(TypeName)与数据库支持的类型之间的映射
            _storeTypeMappings = new Dictionary <string, RelationalTypeMapping>(StringComparer.OrdinalIgnoreCase)
            {
                { "number(1)", _bool },
                { "number(3)", _byte },
                { "number(5)", _short },
                { "number(10)", _int },
                { "number(19)", _long },
                { "number(17,4)", _real },
                { "number(26,9)", _real },                 // 兼容
                { "number(29,9)", _decimal },
                { "decimal(17,4)", _real },
                { "decimal(29,9)", _decimal },
                { "binary_integer", _int },
                { "binary_float", _float },
                { "binary_double", _double },
                { "char", _fixedLengthAnsiString },
                { "nchar", _fixedLengthUnicodeString },
                { "varchar2", _variableLengthAnsiString },
                { "nvarchar2", _variableLengthUnicodeString },
                { "long", _variableLengthAnsiString },
                { "long raw", _variableLengthBinary },
                { "clob", _unboundedAnsiString },
                { "nclob", _unboundedUnicodeString },
                { "blob", _variableLengthBinary },
                { "bfile", _variableLengthBinary },
                { "date", _date },
                { "timestamp", _datetime },
                { "timestamp(0) with time zone", _datetimeoffset },
                { "timestamp(1) with time zone", _datetimeoffset },
                { "timestamp(2) with time zone", _datetimeoffset },
                { "timestamp(3) with time zone", _datetimeoffset3 },
                { "timestamp(4) with time zone", _datetimeoffset },
                { "timestamp(5) with time zone", _datetimeoffset },
                { "timestamp(6) with time zone", _datetimeoffset },
                { "timestamp(7) with time zone", _datetimeoffset },
                { "timestamp(8) with time zone", _datetimeoffset },
                { "timestamp(9) with time zone", _datetimeoffset },
                { "timestamp with time zone", _datetimeoffset },
                { "timestamp(0) with local time zone", _datetimeoffsetlocal },
                { "timestamp(1) with local time zone", _datetimeoffsetlocal },
                { "timestamp(2) with local time zone", _datetimeoffsetlocal },
                { "timestamp(3) with local time zone", _datetimeoffsetlocal },
                { "timestamp(4) with local time zone", _datetimeoffsetlocal },
                { "timestamp(5) with local time zone", _datetimeoffsetlocal },
                { "timestamp(6) with local time zone", _datetimeoffsetlocal },
                { "timestamp(7) with local time zone", _datetimeoffsetlocal },
                { "timestamp(8) with local time zone", _datetimeoffsetlocal },
                { "timestamp(9) with local time zone", _datetimeoffsetlocal },
                { "timestamp with local time zone", _datetimeoffsetlocal },
                { "interval", _time },
                { "interval day", _time },
                { "interval year", _timeYTM },
                { "ROWID", _fixedLengthAnsiString },
                { "UROWID", _urowID },
                { "XMLTYPE", _xml },
                { "xml", _xml }
            };

            if (Check.IsTraceEnabled(m_oracleLogger?.Logger))
            {
                Trace <DbLoggerCategory.Model> .Write(m_oracleLogger, LogLevel.Trace, OracleTraceTag.Exit, OracleTraceClassName.OracleTypeMappingSource, OracleTraceFuncName.ctor);
            }
        }
 public MongoTypeMappingSource(
     TypeMappingSourceDependencies dependencies) :
     base(dependencies)
 {
 }
Exemplo n.º 5
0
 public TestRelationalTypeMappingSource(
     TypeMappingSourceDependencies dependencies,
     RelationalTypeMappingSourceDependencies relationalDependencies)
     : base(dependencies, relationalDependencies)
 {
 }
 public TypeMapperWrapper([NotNull] TypeMappingSourceDependencies dependencies,
                          [NotNull] RelationalTypeMappingSourceDependencies relationalDependencies)
     : base(dependencies, relationalDependencies)
 {
 }
Exemplo n.º 7
0
 public ElasticTypeMappingSource([NotNull] TypeMappingSourceDependencies dependencies) : base(dependencies)
 {
 }
 /// <summary>
 ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
 ///     directly from your code. This API may change or be removed in future releases.
 /// </summary>
 public SqliteTypeMappingSource(
     [NotNull] TypeMappingSourceDependencies dependencies,
     [NotNull] RelationalTypeMappingSourceDependencies relationalDependencies)
     : base(dependencies, relationalDependencies)
 {
 }
Exemplo n.º 9
0
        public OpenEdgeTypeMappingSource(TypeMappingSourceDependencies dependencies, RelationalTypeMappingSourceDependencies relationalDependencies)
            : base(dependencies, relationalDependencies)
        {
            _clrTypeMappings
                = new Dictionary <Type, RelationalTypeMapping>
                {
                { typeof(int), _integer },
                { typeof(long), _bigint },
                { typeof(DateTime), _datetime },
                { typeof(bool), _boolean },
                { typeof(byte), _tinyint },
                { typeof(byte[]), _binary },
                { typeof(double), _double },
                { typeof(DateTimeOffset), _datetime },
                { typeof(short), _smallint },
                { typeof(float), _float },
                { typeof(decimal), _decimal },
                { typeof(TimeSpan), _time }
                };

            _storeTypeMappings
                = new Dictionary <string, RelationalTypeMapping>(StringComparer.OrdinalIgnoreCase)
                {
                { "bigint", _bigint },
                { "int64", _bigint },
                { "binary varying", _binary },
                { "raw", _binary },
                { "binary", _binary },
                { "bit", _boolean },
                { "logical", _boolean },
                { "char varying", _char },
                { "char", _char },
                { "character varying", _char },
                { "character", _char },
                { "date", _date },
                { "datetime", _datetime },
                { "datetime2", _datetime },
                { "datetimeoffset", _datetimeOffset },
                { "datetime-tz", _datetimeOffset },
                { "dec", _decimal },
                { "decimal", _decimal },
                { "double precision", _double },
                { "float", _double },
                { "image", _binary },
                { "int", _integer },
                { "integer", _integer },
                { "money", _decimal },
                { "numeric", _decimal },
                { "real", _float },
                { "smalldatetime", _datetime },
                { "smallint", _smallint },
                { "short", _smallint },
                { "smallmoney", _decimal },
                { "text", _char },
                { "time", _time },
                { "timestamp", _timeStamp },
                { "tinyint", _tinyint },
                { "varbinary", _binary },
                { "varchar", _varchar }
                };
        }
Exemplo n.º 10
0
        /// <summary>
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        public JetTypeMappingSource(
            [NotNull] TypeMappingSourceDependencies dependencies,
            [NotNull] RelationalTypeMappingSourceDependencies relationalDependencies)
            : base(dependencies, relationalDependencies)
        {
            _storeTypeMappings
                = new Dictionary <string, RelationalTypeMapping>(StringComparer.OrdinalIgnoreCase)
                {
                { "binary", _fixedLengthBinary },
                { "bit", _bool },
                { "byte", _byte },
                { "char", _fixedLengthUnicodeString },
                { "date", _date },
                { "datetime", _datetime },
                { "decimal", _decimal },
                { "float", _double },
                { "double", _double },
                { "image", _variableLengthBinary },
                { "int", _int },
                { "guid", _uniqueidentifier },
                { "money", _decimal },
                { "numeric", _decimal },
                { "real", _real },
                { "single", _real },
                { "smalldatetime", _datetime },
                { "smallint", _short },
                { "smallmoney", _decimal },
                { "text", _variableLengthUnicodeString },
                { "time", _time },
                { "timestamp", _rowversion },
                { "tinyint", _byte },
                { "uniqueidentifier", _uniqueidentifier },
                { "varbinary", _variableLengthBinary },
                { "varchar", _variableLengthUnicodeString },
                { "xml", _xml }
                };

            // Note: sbyte, ushort, uint, char and ulong type mappings are not supported by Jet.
            // We would need the type conversions feature to allow this to work - see https://github.com/aspnet/EntityFramework/issues/242.
            _clrTypeMappings
                = new Dictionary <Type, RelationalTypeMapping>
                {
                { typeof(int), _int },
                { typeof(long), _long },
                { typeof(DateTime), _datetime },
                { typeof(Guid), _uniqueidentifier },
                { typeof(bool), _bool },
                { typeof(byte), _byte },
                { typeof(double), _double },
                { typeof(DateTimeOffset), _datetimeoffset },
                { typeof(short), _short },
                { typeof(float), _real },
                { typeof(decimal), _decimal },
                { typeof(TimeSpan), _time }
                };

            // These are disallowed only if specified without any kind of length specified in parenthesis.
            // This is because we don't try to make a new type from this string and any max length value
            // specified in the model, which means use of these strings is almost certainly an error, and
            // if it is not an error, then using, for example, varbinary(1) will work instead.
            _disallowedMappings
                = new HashSet <string>(StringComparer.OrdinalIgnoreCase)
                {
                "binary varying",
                "binary",
                "char varying",
                "char",
                "character varying",
                "character",
                "national char varying",
                "national character varying",
                "national character",
                "nchar",
                "nvarchar",
                "varbinary",
                "varchar"
                };
        }
Exemplo n.º 11
0
 /// <inheritdoc />
 public MongoDbTypeMappingSource([NotNull] TypeMappingSourceDependencies dependencies)
     : base(dependencies)
 {
 }
        public SpannerTypeMappingSource(
            TypeMappingSourceDependencies dependencies,
            RelationalTypeMappingSourceDependencies relationalDependencies)
            : base(dependencies, relationalDependencies)
        {
            _clrTypeMappings
                = new Dictionary <System.Type, RelationalTypeMapping>
                {
                { typeof(short), s_short },
                { typeof(int), s_int },
                { typeof(long), s_long },
                { typeof(decimal), s_numeric },
                { typeof(SpannerNumeric), s_numeric },
                { typeof(uint), s_uint },
                { typeof(bool), s_bool },
                { typeof(SpannerDate), s_date },
                { typeof(DateTime), s_datetime },
                { typeof(float), s_float },
                { typeof(double), s_double },
                { typeof(string), s_defaultString },
                { typeof(char), s_char },
                { typeof(Guid), s_guid },
                { typeof(Regex), s_defaultString },
                { typeof(byte), s_byte },
                { typeof(sbyte), s_sbyte },
                { typeof(ulong), s_ulong },
                { typeof(ushort), s_ushort },
                { typeof(byte[]), s_bytes },

                { typeof(decimal[]), s_numericArray },
                { typeof(decimal?[]), s_nullableNumericArray },
                { typeof(SpannerNumeric[]), s_numericArray },
                { typeof(SpannerNumeric?[]), s_nullableNumericArray },
                { typeof(List <decimal>), s_numericList },
                { typeof(List <decimal?>), s_nullableNumericList },
                { typeof(List <SpannerNumeric>), s_numericList },
                { typeof(List <SpannerNumeric?>), s_nullableNumericList },
                { typeof(string[]), s_stringArray },
                { typeof(List <string>), s_stringList },
                { typeof(bool[]), s_boolArray },
                { typeof(bool?[]), s_nullableBoolArray },
                { typeof(List <bool>), s_boolList },
                { typeof(List <bool?>), s_nullableBoolList },
                { typeof(double[]), s_doubleArray },
                { typeof(double?[]), s_nullableDoubleArray },
                { typeof(List <double>), s_doubleList },
                { typeof(List <double?>), s_nullableDoubleList },
                { typeof(long[]), s_longArray },
                { typeof(long?[]), s_nullableLongArray },
                { typeof(List <long>), s_longList },
                { typeof(List <long?>), s_nullableLongList },
                { typeof(SpannerDate[]), s_dateArray },
                { typeof(SpannerDate?[]), s_nullableDateArray },
                { typeof(List <SpannerDate>), s_dateList },
                { typeof(List <SpannerDate?>), s_nullableDateList },
                { typeof(List <DateTime>), s_timestampList },
                { typeof(List <DateTime?>), s_nullableTimestampList },
                { typeof(DateTime[]), s_timestampArray },
                { typeof(DateTime?[]), s_nullableTimestampArray },
                { typeof(byte[][]), s_byteArray },
                { typeof(List <byte[]>), s_byteList },
                };

            _storeTypeMappings = new Dictionary <string, RelationalTypeMapping>
            {
                { SpannerDbType.Bool.ToString(), s_bool },
                { SpannerDbType.Bytes.ToString(), s_bytes },
                { SpannerDbType.Date.ToString(), s_date },
                { SpannerDbType.Float64.ToString(), s_double },
                { SpannerDbType.Int64.ToString(), s_long },
                { SpannerDbType.Timestamp.ToString(), s_datetime },
                { SpannerDbType.String.ToString(), s_defaultString },
                { SpannerDbType.Numeric.ToString(), s_numeric },
                { "ARRAY<BOOL>", s_nullableBoolList },
                { "ARRAY<BYTES", s_byteList },
                { "ARRAY<DATE>", s_nullableDateList },
                { "ARRAY<FLOAT64>", s_nullableDoubleList },
                { "ARRAY<INT64>", s_nullableLongList },
                { "ARRAY<STRING", s_stringList },
                { "ARRAY<TIMESTAMP>", s_nullableTimestampList },
                { "ARRAY<NUMERIC>", s_nullableNumericList }
            };

            _arrayTypeMappings = new Dictionary <string, RelationalTypeMapping>
            {
                { "ARRAY<BOOL>", s_nullableBoolArray },
                { "ARRAY<BYTES", s_byteArray },
                { "ARRAY<DATE>", s_nullableDateArray },
                { "ARRAY<FLOAT64>", s_nullableDoubleArray },
                { "ARRAY<INT64>", s_nullableLongArray },
                { "ARRAY<STRING", s_stringArray },
                { "ARRAY<TIMESTAMP>", s_nullableTimestampArray },
                { "ARRAY<NUMERIC>", s_nullableNumericArray }
            };
        }
 public FileContextTypeMappingSource([NotNull] TypeMappingSourceDependencies dependencies)
     : base(dependencies)
 {
 }
Exemplo n.º 14
0
 /// <summary>
 ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
 ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
 ///     any release. You should only use it directly in your code with extreme caution and knowing that
 ///     doing so can result in application failures when updating to a new Entity Framework Core release.
 /// </summary>
 public InMemoryTypeMappingSource(TypeMappingSourceDependencies dependencies)
     : base(dependencies)
 {
 }
Exemplo n.º 15
0
        /// <summary>
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        public JetTypeMappingSource(
            [NotNull] TypeMappingSourceDependencies dependencies,
            [NotNull] RelationalTypeMappingSourceDependencies relationalDependencies,
            [NotNull] IJetOptions options)
            : base(dependencies, relationalDependencies)
        {
            // References:
            // https://docs.microsoft.com/en-us/previous-versions/office/developer/office2000/aa140015(v=office.10)
            // https://docs.microsoft.com/en-us/office/vba/access/concepts/error-codes/comparison-of-data-types
            // https://support.office.com/en-us/article/equivalent-ansi-sql-data-types-7a0a6bef-ef25-45f9-8a9a-3c5f21b5c65d
            // https://sourcedaddy.com/ms-access/sql-data-types.html

            // TODO: Check the types and their mappings against
            //       https://docs.microsoft.com/en-us/previous-versions/office/developer/office2000/aa140015(v=office.10)

            _datetime       = new JetDateTimeTypeMapping("datetime", options, dbType: DbType.DateTime);
            _datetimeoffset = new JetDateTimeOffsetTypeMapping("datetime", options);
            _date           = new JetDateTimeTypeMapping("datetime", options, dbType: DbType.Date);
            _time           = new JetTimeSpanTypeMapping("datetime", options);

            _storeTypeMappings
                = new Dictionary <string, RelationalTypeMapping>(StringComparer.OrdinalIgnoreCase)
                {
                { "binary", _fixedLengthBinary },

                { "varbinary", _variableLengthBinary },
                { "binary varying", _variableLengthBinary },
                { "bit varying", _variableLengthBinary },

                { "longbinary", _unboundedBinary },
                { "general", _unboundedBinary },
                { "image", _unboundedBinary },
                { "oleobject", _unboundedBinary },

                { "bit", _bit },
                { "boolean", _bit },
                { "logical", _bit },
                { "logical1", _bit },
                { "yesno", _bit },

                { "counter", _counter },
                { "identity", _counter },
                { "autoincrement", _counter },

                { "byte", _byte },
                { "tinyint", _byte },
                { "integer1", _byte },

                { "smallint", _smallint },
                { "short", _smallint },
                { "integer2", _smallint },

                { "integer", _integer },
                { "long", _integer },
                { "int", _integer },
                { "integer4", _integer },

                { "single", _single },
                { "real", _single },
                { "float4", _single },
                { "ieeesingle", _single },

                { "double", _double },
                { "float", _double },
                { "float8", _double },
                { "ieeedouble", _double },
                { "number", _double },

                { "decimal", _decimal },
                { "numeric", _decimal },
                { "dec", _decimal },

                { "currency", _currency },
                { "money", _currency },

                { "datetime", _datetime },
                { "date", _date },
                { "time", _time },

                { "char", _fixedLengthUnicodeString },
                { "alphanumeric", _fixedLengthUnicodeString },
                { "character", _fixedLengthUnicodeString },
                { "nchar", _fixedLengthUnicodeString },
                { "national char", _fixedLengthUnicodeString },
                { "national character", _fixedLengthUnicodeString },

                { "varchar", _variableLengthUnicodeString },
                { "string", _variableLengthUnicodeString },
                { "char varying", _variableLengthUnicodeString },
                { "character varying", _variableLengthUnicodeString },
                { "national char varying", _variableLengthUnicodeString },
                { "national character varying", _variableLengthUnicodeString },

                { "longchar", _unboundedUnicodeString },
                { "longtext", _unboundedUnicodeString },
                { "memo", _unboundedUnicodeString },
                { "note", _unboundedUnicodeString },
                { "ntext", _unboundedUnicodeString },

                { "guid", _guid },
                { "uniqueidentifier", _guid },

                { "timestamp", _rowversion },
                };

            // Note: sbyte, ushort, uint, char, long and ulong type mappings are not supported by Jet.
            // We would need the type conversions feature to allow this to work - see https://github.com/aspnet/EntityFramework/issues/242.
            _clrTypeMappings
                = new Dictionary <Type, RelationalTypeMapping>
                {
                { typeof(bool), _bool },
                { typeof(byte), _byte },
                { typeof(sbyte), _smallint },
                { typeof(short), _smallint },
                { typeof(int), _integer },
                // {typeof(long), _bigint}, // uses DECIMAL(28,0)
                { typeof(float), _single },
                { typeof(double), _double },
                { typeof(decimal), _decimal },   // CHECK: Is this supported or do we need to use CURRENCY?
                { typeof(DateTime), _datetime },
                { typeof(DateTimeOffset), _datetimeoffset },
                { typeof(TimeSpan), _time },
                { typeof(Guid), _guid },
                };

            // These are disallowed only if specified without any kind of length specified in parenthesis.
            // This is because we don't try to make a new type from this string and any max length value
            // specified in the model, which means use of these strings is almost certainly an error, and
            // if it is not an error, then using, for example, varbinary(1) will work instead.
            _disallowedMappings
                = new HashSet <string>(StringComparer.OrdinalIgnoreCase)
                {
                "binary",

                "varbinary",
                "image",
                "binary varying",
                "bit varying",

                "char",
                "alphanumeric",
                "character",
                "nchar",
                "national char",
                "national character",

                "varchar",
                "string",
                "char varying",
                "character varying",
                "national char varying",
                "national character varying",
                };
        }
 public JsonTypeMappingSource([NotNullAttribute] TypeMappingSourceDependencies dependencies, [NotNullAttribute] RelationalTypeMappingSourceDependencies relationalDependencies) : base(dependencies, relationalDependencies)
 {
 }
Exemplo n.º 17
0
 public TestTypeMappingSource(TypeMappingSourceDependencies dependencies)
     : base(dependencies)
 {
 }
 /// <summary>
 ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
 ///     directly from your code. This API may change or be removed in future releases.
 /// </summary>
 public CosmosTypeMappingSource([NotNull] TypeMappingSourceDependencies dependencies)
     : base(dependencies)
 {
 }
Exemplo n.º 19
0
        public MySqlTypeMappingSource(
            [NotNull] TypeMappingSourceDependencies dependencies,
            [NotNull] RelationalTypeMappingSourceDependencies relationalDependencies,
            [NotNull] IMySqlOptions options)
            : base(dependencies, relationalDependencies)
        {
            _options = options;

            _storeTypeMappings
                = new Dictionary <string, RelationalTypeMapping>(StringComparer.OrdinalIgnoreCase)
                {
                // boolean
                { "bit", _bit },

                // integers
                { "tinyint", _tinyint },
                { "tinyint unsigned", _utinyint },
                { "smallint", _smallint },
                { "smallint unsigned", _usmallint },
                { "mediumint", _int },
                { "mediumint unsigned", _uint },
                { "int", _int },
                { "int unsigned", _uint },
                { "bigint", _bigint },
                { "bigint unsigned", _ubigint },

                // decimals
                { "decimal", _decimal },
                { "dec", _decimal },
                { "fixed", _decimal },
                { "double", _double },
                { "double precision", _double },
                { "real", _double },
                { "float", _float },

                // binary
                { "binary", _binary },
                { "varbinary", _varbinary },
                { "tinyblob", _varbinary },
                { "blob", _varbinary },
                { "mediumblob", _varbinary },
                { "longblob", _varbinary },

                // string
                { "char", _char },
                { "varchar", _varchar },
                { "nchar", _nchar },
                { "nvarchar", _nvarchar },
                { "tinytext", _varcharmax },
                { "text", _varcharmax },
                { "mediumtext", _varcharmax },
                { "longtext", _varcharmax },

                // DateTime
                { "date", _date }
                };

            _unicodeStoreTypeMappings
                = new Dictionary <string, RelationalTypeMapping>(StringComparer.OrdinalIgnoreCase)
                {
                { "char", _nchar },
                { "varchar", _nvarchar },
                { "nchar", _nchar },
                { "nvarchar", _nvarchar },
                { "tinytext", _nvarcharmax },
                { "text", _nvarcharmax },
                { "mediumtext", _nvarcharmax },
                { "longtext", _nvarcharmax }
                };

            _clrTypeMappings
                = new Dictionary <Type, RelationalTypeMapping>
                {
                // boolean
                { typeof(bool), _bit },

                // integers
                { typeof(short), _smallint },
                { typeof(ushort), _usmallint },
                { typeof(int), _int },
                { typeof(uint), _uint },
                { typeof(long), _bigint },
                { typeof(ulong), _ubigint },

                // decimals
                { typeof(decimal), _decimal },
                { typeof(float), _float },
                { typeof(double), _double },

                // byte / char
                { typeof(sbyte), _tinyint },
                { typeof(byte), _utinyint }
                };

            // guid
            _clrTypeMappings[typeof(Guid)] = _options.ConnectionSettings.OldGuids
                ? _oldGuid
                : _uniqueidentifier;

            // DateTime
            if (_options.ServerVersion.SupportsDateTime6)
            {
                _storeTypeMappings["time"]               = _time6;
                _clrTypeMappings[typeof(DateTime)]       = _dateTime6;
                _clrTypeMappings[typeof(DateTimeOffset)] = _dateTimeOffset6;
                _clrTypeMappings[typeof(TimeSpan)]       = _time6;
            }
            else
            {
                _storeTypeMappings["time"]               = _time;
                _clrTypeMappings[typeof(DateTime)]       = _dateTime;
                _clrTypeMappings[typeof(DateTimeOffset)] = _dateTimeOffset;
                _clrTypeMappings[typeof(TimeSpan)]       = _time;
            }
        }
 public ReplacementTypeMappingSource(
     TypeMappingSourceDependencies dependencies,
     RelationalTypeMappingSourceDependencies relationalDependencies)
     : base(dependencies, relationalDependencies)
 {
 }
 public InfoCarrierTypeMappingSource(TypeMappingSourceDependencies dependencies)
     : base(dependencies)
 {
 }
Exemplo n.º 22
0
        /// <summary>
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        public MySqlTypeMappingSource(
            [NotNull] TypeMappingSourceDependencies dependencies,
            [NotNull] RelationalTypeMappingSourceDependencies relationalDependencies)
            : base(dependencies, relationalDependencies)
        {
            _clrTypeMappings
                = new Dictionary <Type, RelationalTypeMapping>
                {
                { typeof(int), _int },
                { typeof(long), _long },
                { typeof(DateTime), _datetime2 },
                { typeof(Guid), _uniqueidentifier },
                { typeof(bool), _bool },
                { typeof(byte), _byte },
                { typeof(double), _double },
                { typeof(DateTimeOffset), _datetimeoffset },
                { typeof(short), _short },
                { typeof(float), _real },
                { typeof(decimal), _decimal },
                { typeof(TimeSpan), _time }
                };

            _storeTypeMappings
                = new Dictionary <string, RelationalTypeMapping>(StringComparer.OrdinalIgnoreCase)
                {
                { "bigint", _long },
                { "binary varying", _variableLengthBinary },
                { "binary", _fixedLengthBinary },
                { "bit", _bool },
                { "char varying", _variableLengthAnsiString },
                { "char", _fixedLengthAnsiString },
                { "character varying", _variableLengthAnsiString },
                { "character", _fixedLengthAnsiString },
                { "date", _date },
                { "datetime", _datetime },
                { "datetime2", _datetime2 },
                { "datetimeoffset", _datetimeoffset },
                { "dec", _decimal },
                { "decimal", _decimal },
                { "double precision", _double },
                { "float", _double },
                { "image", _variableLengthBinary },
                { "int", _int },
                { "money", _money },
                { "national char varying", _variableLengthUnicodeString },
                { "national character varying", _variableLengthUnicodeString },
                { "national character", _fixedLengthUnicodeString },
                { "nchar", _fixedLengthUnicodeString },
                { "ntext", _variableLengthUnicodeString },
                { "numeric", _decimal },
                { "nvarchar", _variableLengthUnicodeString },
                { "nvarchar(max)", _variableLengthMaxUnicodeString },
                { "real", _real },
                { "rowversion", _rowversion },
                { "smalldatetime", _datetime },
                { "smallint", _short },
                { "smallmoney", _money },
                { "sql_variant", _sqlVariant },
                { "text", _variableLengthAnsiString },
                { "time", _time },
                { "timestamp", _rowversion },
                { "tinyint", _byte },
                { "uniqueidentifier", _uniqueidentifier },
                { "varbinary", _variableLengthBinary },
                { "varbinary(max)", _variableLengthMaxBinary },
                { "varchar", _variableLengthAnsiString },
                { "varchar(max)", _variableLengthMaxAnsiString },
                { "xml", _xml }
                };
        }
 /// <summary>
 ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
 ///     directly from your code. This API may change or be removed in future releases.
 /// </summary>
 public LiteDBTypeMappingSource([NotNull] TypeMappingSourceDependencies dependencies)
     : base(dependencies)
 {
 }