@@ -275,97 +275,10 @@ public string GetDataTypeName(int ordinal)
275
275
if ( ordinal < 0 || ordinal > ColumnDefinitions . Length )
276
276
throw new ArgumentOutOfRangeException ( nameof ( ordinal ) , "value must be between 0 and {0}." . FormatInvariant ( ColumnDefinitions . Length ) ) ;
277
277
278
- switch ( ColumnTypes [ ordinal ] )
279
- {
280
- case MySqlDbType . Bool :
281
- return "BOOL" ;
282
-
283
- case MySqlDbType . UByte :
284
- case MySqlDbType . Byte :
285
- return "TINYINT" ;
286
-
287
- case MySqlDbType . UInt16 :
288
- case MySqlDbType . Int16 :
289
- return "SMALLINT" ;
290
-
291
- case MySqlDbType . UInt24 :
292
- case MySqlDbType . Int24 :
293
- return "MEDIUMINT" ;
294
-
295
- case MySqlDbType . UInt32 :
296
- case MySqlDbType . Int32 :
297
- return "INT" ;
298
-
299
- case MySqlDbType . UInt64 :
300
- case MySqlDbType . Int64 :
301
- return "BIGINT" ;
302
-
303
- case MySqlDbType . Bit :
304
- return "BIT" ;
305
-
306
- case MySqlDbType . Enum :
307
- return "ENUM" ;
308
-
309
- case MySqlDbType . Set :
310
- return "SET" ;
311
-
312
- case MySqlDbType . Guid :
313
- return "CHAR(36)" ;
314
-
315
- case MySqlDbType . String :
316
- var columnDefinition = ColumnDefinitions [ ordinal ] ;
317
- return string . Format ( CultureInfo . InvariantCulture , "CHAR({0})" , columnDefinition . ColumnLength / SerializationUtility . GetBytesPerCharacter ( columnDefinition . CharacterSet ) ) ;
318
-
319
- case MySqlDbType . VarString :
320
- case MySqlDbType . TinyText :
321
- case MySqlDbType . Text :
322
- case MySqlDbType . MediumText :
323
- case MySqlDbType . LongText :
324
- return "VARCHAR" ;
325
-
326
- case MySqlDbType . Binary :
327
- case MySqlDbType . VarBinary :
328
- case MySqlDbType . TinyBlob :
329
- case MySqlDbType . Blob :
330
- case MySqlDbType . MediumBlob :
331
- case MySqlDbType . LongBlob :
332
- return "BLOB" ;
333
-
334
- case MySqlDbType . Date :
335
- return "DATE" ;
336
-
337
- case MySqlDbType . DateTime :
338
- return "DATETIME" ;
339
-
340
- case MySqlDbType . Timestamp :
341
- return "TIMESTAMP" ;
342
-
343
- case MySqlDbType . Time :
344
- return "TIME" ;
345
-
346
- case MySqlDbType . Year :
347
- return "YEAR" ;
348
-
349
- case MySqlDbType . Float :
350
- return "FLOAT" ;
351
-
352
- case MySqlDbType . Double :
353
- return "DOUBLE" ;
354
-
355
- case MySqlDbType . Decimal :
356
- case MySqlDbType . NewDecimal :
357
- return "DECIMAL" ;
358
-
359
- case MySqlDbType . JSON :
360
- return "JSON" ;
361
-
362
- case MySqlDbType . Null :
363
- // not a valid data type name, but only happens when there is no way to infer the type of the column, e.g., "SELECT NULL;"
364
- return "NULL" ;
365
-
366
- default :
367
- throw new NotImplementedException ( "GetDataTypeName for {0} is not implemented" . FormatInvariant ( ColumnTypes [ ordinal ] ) ) ;
368
- }
278
+ var mySqlDbType = ColumnTypes [ ordinal ] ;
279
+ if ( mySqlDbType == MySqlDbType . String )
280
+ return string . Format ( CultureInfo . InvariantCulture , "CHAR({0})" , ColumnDefinitions [ ordinal ] . ColumnLength / SerializationUtility . GetBytesPerCharacter ( ColumnDefinitions [ ordinal ] . CharacterSet ) ) ;
281
+ return TypeMapper . Mapper . GetColumnMapping ( mySqlDbType ) . SimpleDataTypeName ;
369
282
}
370
283
371
284
public Type GetFieldType ( int ordinal )
0 commit comments