@@ -195,6 +195,8 @@ public short GetInt16(int ordinal)
195195 return checked ( ( short ) ( ulong ) value ) ;
196196 if ( value is decimal )
197197 return ( short ) ( decimal ) value ;
198+ if ( value is bool )
199+ return ( bool ) value ? ( short ) 1 : ( short ) 0 ;
198200 return ( short ) value ;
199201 }
200202
@@ -207,16 +209,15 @@ public int GetInt32(int ordinal)
207209 throw new InvalidCastException ( ) ;
208210
209211 var columnDefinition = ResultSet . ColumnDefinitions [ ordinal ] ;
210- if ( ( columnDefinition . ColumnType != ColumnType . Tiny &&
212+ if ( columnDefinition . ColumnType != ColumnType . Tiny &&
211213 columnDefinition . ColumnType != ColumnType . Short &&
212214 columnDefinition . ColumnType != ColumnType . Int24 &&
213215 columnDefinition . ColumnType != ColumnType . Long &&
214216 columnDefinition . ColumnType != ColumnType . Longlong &&
215217 columnDefinition . ColumnType != ColumnType . Bit &&
216218 columnDefinition . ColumnType != ColumnType . Year &&
217219 columnDefinition . ColumnType != ColumnType . Decimal &&
218- columnDefinition . ColumnType != ColumnType . NewDecimal ) ||
219- ( columnDefinition . ColumnType == ColumnType . Tiny && Connection . TreatTinyAsBoolean && columnDefinition . ColumnLength == 1 && ( columnDefinition . ColumnFlags & ColumnFlags . Unsigned ) == 0 ) )
220+ columnDefinition . ColumnType != ColumnType . NewDecimal )
220221 {
221222 throw new InvalidCastException ( "Can't convert {0} to Int32" . FormatInvariant ( ResultSet . ColumnTypes ! [ ordinal ] ) ) ;
222223 }
@@ -252,6 +253,8 @@ public long GetInt64(int ordinal)
252253 return checked ( ( long ) ( ulong ) value ) ;
253254 if ( value is decimal )
254255 return ( long ) ( decimal ) value ;
256+ if ( value is bool )
257+ return ( bool ) value ? 1 : 0 ;
255258 return ( long ) value ;
256259 }
257260
@@ -277,6 +280,8 @@ public ushort GetUInt16(int ordinal)
277280 return checked ( ( ushort ) ( ulong ) value ) ;
278281 if ( value is decimal )
279282 return ( ushort ) ( decimal ) value ;
283+ if ( value is bool )
284+ return ( bool ) value ? ( ushort ) 1 : ( ushort ) 0 ;
280285 return ( ushort ) value ;
281286 }
282287
@@ -302,6 +307,8 @@ public uint GetUInt32(int ordinal)
302307 return checked ( ( uint ) ( ulong ) value ) ;
303308 if ( value is decimal )
304309 return ( uint ) ( decimal ) value ;
310+ if ( value is bool )
311+ return ( bool ) value ? ( uint ) 1 : ( uint ) 0 ;
305312 return ( uint ) value ;
306313 }
307314
@@ -327,6 +334,8 @@ public ulong GetUInt64(int ordinal)
327334 return checked ( ( ulong ) ( long ) value ) ;
328335 if ( value is decimal )
329336 return ( ulong ) ( decimal ) value ;
337+ if ( value is bool )
338+ return ( bool ) value ? ( ulong ) 1 : ( ulong ) 0 ;
330339 return ( ulong ) value ;
331340 }
332341
0 commit comments