コード例 #1
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 SqlServerCoreTypeMapper(
     [NotNull] CoreTypeMapperDependencies dependencies,
     [NotNull] RelationalTypeMapperDependencies relationalDependencies,
     [NotNull] IRelationalTypeMapper typeMapper)
     : base(dependencies, relationalDependencies, typeMapper)
 {
 }
コード例 #2
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 SqliteTypeMapper(
            [NotNull] CoreTypeMapperDependencies coreDependencies,
            [NotNull] RelationalTypeMapperDependencies dependencies)
            : base(coreDependencies, dependencies)
        {
            _storeTypeMappings
                = new Dictionary <string, IList <RelationalTypeMapping> >(StringComparer.OrdinalIgnoreCase);

            _clrTypeMappings
                = new Dictionary <Type, RelationalTypeMapping>
                {
                { typeof(string), _text },
                { typeof(byte[]), _blob },
                { typeof(bool), new BoolTypeMapping(_integerTypeName) },
                { typeof(byte), new ByteTypeMapping(_integerTypeName) },
                { typeof(char), new CharTypeMapping(_integerTypeName) },
                { typeof(int), new IntTypeMapping(_integerTypeName) },
                { typeof(long), _integer },
                { typeof(sbyte), new SByteTypeMapping(_integerTypeName) },
                { typeof(short), new ShortTypeMapping(_integerTypeName) },
                { typeof(uint), new UIntTypeMapping(_integerTypeName) },
                { typeof(ulong), new ULongTypeMapping(_integerTypeName) },
                { typeof(ushort), new UShortTypeMapping(_integerTypeName) },
                { typeof(DateTime), new SqliteDateTimeTypeMapping(_textTypeName) },
                { typeof(DateTimeOffset), new SqliteDateTimeOffsetTypeMapping(_textTypeName) },
                { typeof(TimeSpan), new TimeSpanTypeMapping(_textTypeName) },
                { typeof(decimal), new DecimalTypeMapping(_textTypeName) },
                { typeof(double), _real },
                { typeof(float), new FloatTypeMapping(_realTypeName) },
                { typeof(Guid), new SqliteGuidTypeMapping(_blobTypeName) }
                };
        }
コード例 #3
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 FallbackRelationalCoreTypeMapper(
     [NotNull] CoreTypeMapperDependencies dependencies,
     [NotNull] RelationalTypeMapperDependencies relationalDependencies,
     [NotNull] IRelationalTypeMapper typeMapper)
     : base(dependencies, relationalDependencies)
 {
     _relationalTypeMapper = typeMapper;
 }
コード例 #4
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 FallbackCoreTypeMapper(
            [NotNull] CoreTypeMapperDependencies dependencies,
            [NotNull] ITypeMapper typeMapper)
            : base(dependencies)
        {
            Check.NotNull(typeMapper, nameof(typeMapper));

            _typeMapper = typeMapper;
        }
コード例 #5
0
            public SqlServerStringsTypeMapper(
                CoreTypeMapperDependencies coreDependencies,
                RelationalTypeMapperDependencies dependencies)
                : base(coreDependencies, dependencies)
            {
                _storeTypeMappings
                    = new Dictionary <string, IList <RelationalTypeMapping> >(StringComparer.OrdinalIgnoreCase)
                    {
                    {
                        "national char varying", new List <RelationalTypeMapping>
                        {
                            _variableLengthUnicodeString
                        }
                    },
                    {
                        "national character varying", new List <RelationalTypeMapping>
                        {
                            _variableLengthUnicodeString
                        }
                    },
                    {
                        "nvarchar", new List <RelationalTypeMapping>
                        {
                            _variableLengthUnicodeString
                        }
                    }
                    };

                _clrTypeMappings = new Dictionary <Type, RelationalTypeMapping>();

                StringMapper
                    = new StringRelationalTypeMapper(
                          maxBoundedAnsiLength: 4000,
                          defaultAnsiMapping: _unboundedUnicodeString,
                          unboundedAnsiMapping: _unboundedUnicodeString,
                          keyAnsiMapping: _keyUnicodeString,
                          createBoundedAnsiMapping: size => new SqlServerStringTypeMapping(
                              "nvarchar(" + size + ")",
                              dbType: null,
                              unicode: true,
                              size: size),
                          maxBoundedUnicodeLength: 4000,
                          defaultUnicodeMapping: _unboundedUnicodeString,
                          unboundedUnicodeMapping: _unboundedUnicodeString,
                          keyUnicodeMapping: _keyUnicodeString,
                          createBoundedUnicodeMapping: size => new SqlServerStringTypeMapping(
                              "nvarchar(" + size + ")",
                              dbType: null,
                              unicode: true,
                              size: size));
            }
コード例 #6
0
            public SqlServerBytesTypeMapper(
                CoreTypeMapperDependencies coreDependencies,
                RelationalTypeMapperDependencies relationalDependencies)
                : base(coreDependencies, relationalDependencies)
            {
                _storeTypeMappings
                    = new Dictionary <string, IList <RelationalTypeMapping> >(StringComparer.OrdinalIgnoreCase)
                    {
                    { "binary varying", new List <RelationalTypeMapping> {
                          _variableLengthBinary
                      } },
                    { "binary", new List <RelationalTypeMapping> {
                          _fixedLengthBinary
                      } },
                    { "image", new List <RelationalTypeMapping> {
                          _variableLengthBinary
                      } },
                    { "rowversion", new List <RelationalTypeMapping> {
                          _rowversion
                      } },
                    { "timestamp", new List <RelationalTypeMapping> {
                          _rowversion
                      } },
                    { "varbinary", new List <RelationalTypeMapping> {
                          _variableLengthBinary
                      } }
                    };

                _clrTypeMappings = new Dictionary <Type, RelationalTypeMapping>();

                ByteArrayMapper
                    = new ByteArrayRelationalTypeMapper(
                          maxBoundedLength: 8000,
                          defaultMapping: _unboundedBinary,
                          unboundedMapping: _unboundedBinary,
                          keyMapping: _keyBinary,
                          rowVersionMapping: _rowversion,
                          createBoundedMapping: size => new SqlServerByteArrayTypeMapping(
                              "varbinary(" + size + ")",
                              DbType.Binary,
                              size));
            }
コード例 #7
0
        public static ConventionSet Build()
        {
            var coreTypeMapperDependencies = new CoreTypeMapperDependencies(
                new ValueConverterSelector(
                    new ValueConverterSelectorDependencies()));

            var oracleTypeMapper = new OracleTypeMapper(
                new RelationalTypeMapperDependencies());

            var convertingMapper = new FallbackRelationalCoreTypeMapper(
                coreTypeMapperDependencies,
                new RelationalTypeMapperDependencies(),
                oracleTypeMapper);

            return(new OracleConventionSetBuilder(
                       new RelationalConventionSetBuilderDependencies(convertingMapper, null, null, null))
                   .AddConventions(
                       new CoreConventionSetBuilder(
                           new CoreConventionSetBuilderDependencies(convertingMapper, null, null, null))
                       .CreateConventionSet()));
        }
コード例 #8
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 static ConventionSet Build()
        {
            var coreTypeMapperDependencies = new CoreTypeMapperDependencies(
                new ValueConverterSelector(
                    new ValueConverterSelectorDependencies()));

            var sqlServerTypeMapper = new SqlServerTypeMapper(
                new RelationalTypeMapperDependencies());

            var convertingTypeMapper = new FallbackRelationalCoreTypeMapper(
                coreTypeMapperDependencies,
                new RelationalTypeMapperDependencies(),
                sqlServerTypeMapper);

            return(new SqlServerConventionSetBuilder(
                       new RelationalConventionSetBuilderDependencies(convertingTypeMapper, null, null, null),
                       new SqlServerSqlGenerationHelper(new RelationalSqlGenerationHelperDependencies()))
                   .AddConventions(
                       new CoreConventionSetBuilder(
                           new CoreConventionSetBuilderDependencies(convertingTypeMapper, null, null))
                       .CreateConventionSet()));
        }
コード例 #9
0
 public ConcreteTypeMapper(
     CoreTypeMapperDependencies coreDependencies,
     RelationalTypeMapperDependencies dependencies)
     : base(coreDependencies, dependencies)
 {
 }
コード例 #10
0
        public OracleTypeMapper(
            [NotNull] CoreTypeMapperDependencies coreDependencies,
            [NotNull] RelationalTypeMapperDependencies dependencies)
            : base(coreDependencies, dependencies)
        {
            _storeTypeMappings
                = new Dictionary <string, IList <RelationalTypeMapping> >(StringComparer.OrdinalIgnoreCase)
                {
                { "number(19)", new List <RelationalTypeMapping> {
                      _long
                  } },
                { "blob", new List <RelationalTypeMapping> {
                      _variableLengthBinary
                  } },
                { "raw", new List <RelationalTypeMapping> {
                      _fixedLengthBinary
                  } },
                { "char", new List <RelationalTypeMapping> {
                      _fixedLengthAnsiString
                  } },
                { "date", new List <RelationalTypeMapping> {
                      _date
                  } },
                { "timestamp", new List <RelationalTypeMapping> {
                      _datetime
                  } },
                { "timestamp(3) with time zone", new List <RelationalTypeMapping> {
                      _datetimeoffset
                  } },
                { "timestamp with time zone", new List <RelationalTypeMapping> {
                      _datetimeoffset
                  } },
                { "number(29,4)", new List <RelationalTypeMapping> {
                      _decimal
                  } },
                { "float(49)", new List <RelationalTypeMapping> {
                      _double
                  } },
                { "number(10)", new List <RelationalTypeMapping> {
                      _int
                  } },
                { "nchar", new List <RelationalTypeMapping> {
                      _fixedLengthUnicodeString
                  } },
                { "nvarchar2", new List <RelationalTypeMapping> {
                      _variableLengthUnicodeString
                  } },
                { "number(6)", new List <RelationalTypeMapping> {
                      _short
                  } },
                { "interval", new List <RelationalTypeMapping> {
                      _time
                  } },
                { "number(3)", new List <RelationalTypeMapping> {
                      _byte
                  } },
                { "varchar2", new List <RelationalTypeMapping> {
                      _variableLengthAnsiString
                  } },
                { "clob", new List <RelationalTypeMapping> {
                      _unboundedUnicodeString, _unboundedAnsiString
                  } },
                { "xml", new List <RelationalTypeMapping> {
                      _xml
                  } }
                };

            _clrTypeMappings
                = new Dictionary <Type, RelationalTypeMapping>
                {
                { typeof(int), _int },
                { typeof(long), _long },
                { typeof(DateTime), _datetime },
                { 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",
                "nvarchar2",
                "varchar2"
                };

            ByteArrayMapper
                = new ByteArrayRelationalTypeMapper(
                      maxBoundedLength: 2000,
                      defaultMapping: _unboundedBinary,
                      unboundedMapping: _unboundedBinary,
                      keyMapping: _keyBinary,
                      rowVersionMapping: _rowversion,
                      createBoundedMapping: size => new OracleByteArrayTypeMapping(
                          "RAW(" + size + ")",
                          DbType.Binary,
                          size));

            StringMapper
                = new StringRelationalTypeMapper(
                      maxBoundedAnsiLength: 4000,
                      defaultAnsiMapping: _defaultAnsiString,
                      unboundedAnsiMapping: _unboundedAnsiString,
                      keyAnsiMapping: _keyAnsiString,
                      createBoundedAnsiMapping: size => new OracleStringTypeMapping(
                          "VARCHAR2(" + size + ")",
                          DbType.AnsiString,
                          unicode: false,
                          size: size),
                      maxBoundedUnicodeLength: 2000,
                      defaultUnicodeMapping: _defaultUnicodeString,
                      unboundedUnicodeMapping: _unboundedUnicodeString,
                      keyUnicodeMapping: _keyUnicodeString,
                      createBoundedUnicodeMapping: size => new OracleStringTypeMapping(
                          "NVARCHAR2(" + size + ")",
                          dbType: null,
                          unicode: true,
                          size: size));
        }
コード例 #11
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 SqlServerTypeMapper(
            [NotNull] CoreTypeMapperDependencies coreDependencies,
            [NotNull] RelationalTypeMapperDependencies dependencies)
            : base(coreDependencies, dependencies)
        {
            _storeTypeMappings
                = new Dictionary <string, IList <RelationalTypeMapping> >(StringComparer.OrdinalIgnoreCase)
                {
                { "bigint", new List <RelationalTypeMapping> {
                      _long, _uintToBigint, _ulong
                  } },
                { "binary varying", new List <RelationalTypeMapping> {
                      _variableLengthBinary
                  } },
                { "binary", new List <RelationalTypeMapping> {
                      _fixedLengthBinary
                  } },
                { "bit", new List <RelationalTypeMapping> {
                      _bool
                  } },
                { "char varying", new List <RelationalTypeMapping> {
                      _variableLengthAnsiString, _ansiVarChar
                  } },
                { "char", new List <RelationalTypeMapping> {
                      _fixedLengthAnsiString, _ansiFixedChar
                  } },
                { "character varying", new List <RelationalTypeMapping> {
                      _variableLengthAnsiString, _ansiVarChar
                  } },
                { "character", new List <RelationalTypeMapping> {
                      _fixedLengthAnsiString, _ansiFixedChar
                  } },
                { "date", new List <RelationalTypeMapping> {
                      _date
                  } },
                { "datetime", new List <RelationalTypeMapping> {
                      _datetime
                  } },
                { "datetime2", new List <RelationalTypeMapping> {
                      _datetime2
                  } },
                { "datetimeoffset", new List <RelationalTypeMapping> {
                      _datetimeoffset
                  } },
                { "dec", new List <RelationalTypeMapping> {
                      _decimal, _ulongToDecimal
                  } },
                { "decimal", new List <RelationalTypeMapping> {
                      _decimal, _ulongToDecimal
                  } },
                { "float", new List <RelationalTypeMapping> {
                      _double
                  } },
                { "image", new List <RelationalTypeMapping> {
                      _variableLengthBinary
                  } },
                { "int", new List <RelationalTypeMapping> {
                      _int, _ushortToInt, _uint, _intChar
                  } },
                { "money", new List <RelationalTypeMapping> {
                      _decimal
                  } },
                { "national char varying", new List <RelationalTypeMapping> {
                      _variableLengthUnicodeString, _unicodeVarChar
                  } },
                { "national character varying", new List <RelationalTypeMapping> {
                      _variableLengthUnicodeString, _unicodeVarChar
                  } },
                { "national character", new List <RelationalTypeMapping> {
                      _fixedLengthUnicodeString, _unicodeFixedChar
                  } },
                { "nchar", new List <RelationalTypeMapping> {
                      _fixedLengthUnicodeString, _unicodeFixedChar
                  } },
                { "ntext", new List <RelationalTypeMapping> {
                      _variableLengthUnicodeString, _unicodeVarChar
                  } },
                { "numeric", new List <RelationalTypeMapping> {
                      _decimal, _ulongToDecimal
                  } },
                { "nvarchar", new List <RelationalTypeMapping> {
                      _variableLengthUnicodeString, _unicodeVarChar
                  } },
                { "real", new List <RelationalTypeMapping> {
                      _real
                  } },
                { "rowversion", new List <RelationalTypeMapping> {
                      _rowversion
                  } },
                { "smalldatetime", new List <RelationalTypeMapping> {
                      _datetime
                  } },
                { "smallint", new List <RelationalTypeMapping> {
                      _short, _sbyteToSmallint, _ushort
                  } },
                { "smallmoney", new List <RelationalTypeMapping> {
                      _decimal
                  } },
                { "text", new List <RelationalTypeMapping> {
                      _variableLengthAnsiString, _ansiVarChar
                  } },
                { "time", new List <RelationalTypeMapping> {
                      _time
                  } },
                { "timestamp", new List <RelationalTypeMapping> {
                      _rowversion
                  } },
                { "tinyint", new List <RelationalTypeMapping> {
                      _byte, _sbyte
                  } },
                { "uniqueidentifier", new List <RelationalTypeMapping> {
                      _uniqueidentifier
                  } },
                { "varbinary", new List <RelationalTypeMapping> {
                      _variableLengthBinary
                  } },
                { "varchar", new List <RelationalTypeMapping> {
                      _variableLengthAnsiString, _ansiVarChar
                  } },
                { "xml", new List <RelationalTypeMapping> {
                      _xml
                  } }
                };

            // Note: sbyte, ushort, uint, char and ulong type mappings are not supported by SQL Server.
            // 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(uint), _uintToBigint },
                { typeof(ulong), _ulongToDecimal },
                { typeof(DateTime), _datetime2 },
                { typeof(Guid), _uniqueidentifier },
                { typeof(bool), _bool },
                { typeof(byte), _byte },
                { typeof(sbyte), _sbyteToSmallint },
                { typeof(double), _double },
                { typeof(DateTimeOffset), _datetimeoffset },
                { typeof(short), _short },
                { typeof(ushort), _ushortToInt },
                { typeof(float), _real },
                { typeof(decimal), _decimal },
                { typeof(TimeSpan), _time },
                { typeof(char), _unicodeFixedChar }
                };

            // 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
                "binary",

                // varbinary
                "binary varying",
                "varbinary",

                // char
                "char",
                "character",

                // varchar
                "char varying",
                "character varying",
                "varchar",

                // nchar
                "national char",
                "national character",
                "nchar",

                // nvarchar
                "national char varying",
                "national character varying",
                "nvarchar"
                };

            ByteArrayMapper
                = new ByteArrayRelationalTypeMapper(
                      maxBoundedLength: 8000,
                      defaultMapping: _unboundedBinary,
                      unboundedMapping: _unboundedBinary,
                      keyMapping: _keyBinary,
                      rowVersionMapping: _rowversion,
                      createBoundedMapping: size => new SqlServerByteArrayTypeMapping(
                          "varbinary(" + size + ")",
                          DbType.Binary,
                          size));

            StringMapper
                = new StringRelationalTypeMapper(
                      maxBoundedAnsiLength: 8000,
                      defaultAnsiMapping: _unboundedAnsiString,
                      unboundedAnsiMapping: _unboundedAnsiString,
                      keyAnsiMapping: _keyAnsiString,
                      createBoundedAnsiMapping: size => new SqlServerStringTypeMapping(
                          "varchar(" + size + ")",
                          DbType.AnsiString,
                          unicode: false,
                          size: size),
                      maxBoundedUnicodeLength: 4000,
                      defaultUnicodeMapping: _unboundedUnicodeString,
                      unboundedUnicodeMapping: _unboundedUnicodeString,
                      keyUnicodeMapping: _keyUnicodeString,
                      createBoundedUnicodeMapping: size => new SqlServerStringTypeMapping(
                          "nvarchar(" + size + ")",
                          dbType: null,
                          unicode: true,
                          size: size));
        }