22using System . Collections . Concurrent ;
33using System . Collections . Generic ;
44using System . Data ;
5+ using EfCore . Ydb . Storage . Internal . Mapping ;
56using Microsoft . EntityFrameworkCore . Storage ;
67
78namespace EfCore . Ydb . Storage . Internal ;
@@ -13,7 +14,22 @@ public class YdbTypeMappingSource : RelationalTypeMappingSource
1314
1415 #region Mappings
1516
17+ private readonly YdbBoolTypeMapping _bool = YdbBoolTypeMapping . Default ;
18+
19+ private readonly SByteTypeMapping _int8 = new ( "INT8" , DbType . Byte ) ;
20+ private readonly ShortTypeMapping _int16 = new ( "INT16" , DbType . Int16 ) ;
1621 private readonly IntTypeMapping _int32 = new ( "INT32" , DbType . Int32 ) ;
22+ private readonly LongTypeMapping _int64 = new ( "INT64" , DbType . Int64 ) ;
23+
24+ private readonly ByteTypeMapping _uint8 = new ( "UINT8" , DbType . SByte ) ;
25+ private readonly UShortTypeMapping _uint16 = new ( "UINT16" , DbType . UInt16 ) ;
26+ private readonly UIntTypeMapping _uint32 = new ( "UINT32" , DbType . UInt32 ) ;
27+ private readonly ULongTypeMapping _uint64 = new ( "UINT64" , DbType . UInt64 ) ;
28+
29+ private readonly FloatTypeMapping _float = new ( "FLOAT" , DbType . Single ) ;
30+ private readonly DoubleTypeMapping _double = new ( "DOUBLE" , DbType . Double ) ;
31+
32+ private readonly StringTypeMapping _string = new ( "STRING" , DbType . String ) ;
1733
1834 #endregion
1935
@@ -24,11 +40,41 @@ RelationalTypeMappingSourceDependencies relationalDependencies
2440 {
2541 var storeTypeMappings = new Dictionary < string , RelationalTypeMapping [ ] > ( StringComparer . OrdinalIgnoreCase )
2642 {
27- { "integer" , [ _int32 ] }
43+ { "bool" , [ _bool ] } ,
44+
45+ { "int8" , [ _int8 ] } ,
46+ { "int16" , [ _int16 ] } ,
47+ { "int32" , [ _int32 ] } ,
48+ { "int64" , [ _int64 ] } ,
49+
50+ { "uint8" , [ _uint8 ] } ,
51+ { "uint16" , [ _uint16 ] } ,
52+ { "uint32" , [ _uint32 ] } ,
53+ { "uint64" , [ _uint64 ] } ,
54+
55+ { "float" , [ _float ] } ,
56+ { "double" , [ _double ] } ,
57+
58+ { "string" , [ _string ] }
2859 } ;
2960 var clrTypeMappings = new Dictionary < Type , RelationalTypeMapping >
3061 {
31- { typeof ( int ) , _int32 }
62+ { typeof ( bool ) , _bool } ,
63+
64+ { typeof ( sbyte ) , _int8 } ,
65+ { typeof ( short ) , _int16 } ,
66+ { typeof ( int ) , _int32 } ,
67+ { typeof ( long ) , _int64 } ,
68+
69+ { typeof ( byte ) , _uint8 } ,
70+ { typeof ( ushort ) , _uint16 } ,
71+ { typeof ( uint ) , _uint32 } ,
72+ { typeof ( ulong ) , _uint64 } ,
73+
74+ { typeof ( float ) , _float } ,
75+ { typeof ( double ) , _double } ,
76+
77+ { typeof ( string ) , _string }
3278 } ;
3379
3480 StoreTypeMapping = new ConcurrentDictionary < string , RelationalTypeMapping [ ] > ( storeTypeMappings ) ;
@@ -66,7 +112,6 @@ RelationalTypeMappingSourceDependencies relationalDependencies
66112 return mapping ;
67113 }
68114 }
69-
70115 return null ;
71116 }
72117}
0 commit comments