Exemplo n.º 1
0
        public MySQLTypeMapper()
        {
            _storeTypeMappings = new Dictionary <string, RelationalTypeMapping>(StringComparer.OrdinalIgnoreCase)
            {
                { "bigint", _bigint },
                { "decimal", _decimal },
                { "double", _double },
                { "float", _double },
                { "int", _int },
                { "mediumint", _int },
                { "real", _real },
                { "smallint", _smallint },
                { "tinyint", _tinyint },
                { "char", _char },
                { "varchar", _varchar },
                { "longtext", _longText },
                { "mediumtext", _mediumText },
                { "text", _Text },
                { "tinytext", _tinyText },
                { "datetime", _datetime },
                { "timestamp", _datetime },
                { "bit", _bit },
                { "blob", _varbinary }
            };

            _clrTypeMappings = new Dictionary <Type, RelationalTypeMapping>
            {
                { typeof(int), _int },
                { typeof(long), _bigint },
                { typeof(DateTime), _datetime },
                { typeof(bool), _bit },
                { typeof(byte), _tinyint },
                { typeof(double), _double },
                { typeof(char), _int },
                { typeof(sbyte), new RelationalTypeMapping("smallint", _smallint.GetType()) },
                { typeof(ushort), new RelationalTypeMapping("int", _int.GetType()) },
                { typeof(uint), new RelationalTypeMapping("bigint", _bigint.GetType()) },
                { typeof(ulong), new RelationalTypeMapping("numeric(20, 0)", _decimal.GetType()) },
                { typeof(short), _smallint },
                { typeof(float), _real },
                { typeof(decimal), _decimal },
                { typeof(byte[]), _varbinary },
                { typeof(string), _varchar }
            };
        }
Exemplo n.º 2
0
        public MySQLTypeMapper()
            : base()
        {
            _storeTypeMappings = new Dictionary <string, RelationalTypeMapping>(StringComparer.OrdinalIgnoreCase)
            {
                { "bigint", _bigint },
                { "decimal", _decimal },
                { "double", _double },
                { "float", _float },
                { "int", _int },
                { "mediumint", _int },
                { "real", _real },
                { "smallint", _smallint },
                { "tinyint", _tinyint },
                { "char", _char },
                { "varchar", _varchar },
                { "tinytext", _tinyText },
                { "text", _text },
                { "mediumtext", _mediumText },
                { "longtext", _longText },
                { "datetime", _datetime },
                { "datetimeoffset", _datetimeoffset },
                { "date", _date },
                { "time", _time },
                { "timestamp", _datetime },
                { "year", _smallint },
                { "bit", _bit },
                { "string", _varchar },
                { "tinyblob", _tinyblob },
                { "blob", _blob },
                { "mediumblob", _mediumblob },
                { "longblob", _longblob },
                { "binary", _binary },
                { "varbinary", _varbinary },
                { "enum", _enum },
                { "set", _set },
                { "json", _varchar }
            };

            _clrTypeMappings = new Dictionary <Type, RelationalTypeMapping>
            {
                { typeof(int), _int },
                { typeof(long), _bigint },
                { typeof(DateTime), _datetime },
                { typeof(DateTimeOffset), _datetimeoffset },
                { typeof(bool), _bit },
                { typeof(byte), _tinyint },
                { typeof(float), _float },
                { typeof(double), _double },
                { typeof(char), _int },
                { typeof(sbyte), _smallint },
                { typeof(ushort), _int },
                { typeof(uint), _bigint },
                { typeof(ulong), new MySQLNumberTypeMapping("numeric(20, 0)", _decimal.GetType()) },
                { typeof(short), _smallint },
                { typeof(decimal), _decimal },
                { typeof(byte[]), _varbinary },
                { typeof(TimeSpan), _time }
            };


            StringMapper
                = new StringRelationalTypeMapper(
                      _textMaxLength,
                      _text,
                      _longText,
                      _varcharkey,
                      size => new MySQLStringTypeMapping(
                          "varchar(" + size + ")",
                          dbType: DbType.AnsiString,
                          unicode: false,
                          size: size,
                          hasNonDefaultUnicode: true),
                      _textMaxLength,
                      _text,
                      _longText,
                      _varcharkey,
                      size => new MySQLStringTypeMapping(
                          "varchar(" + size + ")",
                          dbType: null,
                          unicode: true,
                          size: size,
                          hasNonDefaultUnicode: false));



            ByteArrayMapper
                = new ByteArrayRelationalTypeMapper(
                      _longTextMaxLength,
                      _varbinary,
                      _varbinary,
                      _varbinary,
                      _rowversion, _ => _varbinary);
        }