You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -178,28 +154,20 @@ public Guid GetGuid(int ordinal)
178
154
publicshortGetInt16(intordinal)
179
155
{
180
156
varvalue=GetValue(ordinal);
181
-
if(valueisshort)
182
-
return(short)value;
183
-
184
-
if(valueissbyte)
185
-
return(sbyte)value;
186
-
if(valueisbyte)
187
-
return(byte)value;
188
-
if(valueisushort)
189
-
returnchecked((short)(ushort)value);
190
-
if(valueisint)
191
-
returnchecked((short)(int)value);
192
-
if(valueisuint)
193
-
returnchecked((short)(uint)value);
194
-
if(valueislong)
195
-
returnchecked((short)(long)value);
196
-
if(valueisulong)
197
-
returnchecked((short)(ulong)value);
198
-
if(valueisdecimal)
199
-
return(short)(decimal)value;
200
-
if(valueisbool)
201
-
return(bool)value?(short)1:(short)0;
202
-
return(short)value;
157
+
returnvalueswitch
158
+
{
159
+
shortshortValue=>shortValue,
160
+
sbytesbyteValue=>sbyteValue,
161
+
bytebyteValue=>byteValue,
162
+
ushortushortValue=>checked((short)ushortValue),
163
+
intintValue=>checked((short)intValue),
164
+
uintuintValue=>checked((short)uintValue),
165
+
longlongValue=>checked((short)longValue),
166
+
ulongulongValue=>checked((short)ulongValue),
167
+
decimaldecimalValue=>(short)decimalValue,
168
+
boolboolValue=>boolValue?(short)1:(short)0,
169
+
_ =>(short)value,
170
+
};
203
171
}
204
172
205
173
publicintGetInt32(intordinal)
@@ -242,109 +210,77 @@ and not ColumnType.Int24 and not ColumnType.Long and not ColumnType.Longlong
242
210
publiclongGetInt64(intordinal)
243
211
{
244
212
varvalue=GetValue(ordinal);
245
-
if(valueislong)
246
-
return(long)value;
247
-
248
-
if(valueissbyte)
249
-
return(sbyte)value;
250
-
if(valueisbyte)
251
-
return(byte)value;
252
-
if(valueisshort)
253
-
return(short)value;
254
-
if(valueisushort)
255
-
return(ushort)value;
256
-
if(valueisint)
257
-
return(int)value;
258
-
if(valueisuint)
259
-
return(uint)value;
260
-
if(valueisulong)
261
-
returnchecked((long)(ulong)value);
262
-
if(valueisdecimal)
263
-
return(long)(decimal)value;
264
-
if(valueisbool)
265
-
return(bool)value?1:0;
266
-
return(long)value;
213
+
returnvalueswitch
214
+
{
215
+
longlongValue=>longValue,
216
+
sbytesbyteValue=>sbyteValue,
217
+
bytebyteValue=>byteValue,
218
+
shortshortValue=>shortValue,
219
+
ushortushortValue=>ushortValue,
220
+
intintValue=>intValue,
221
+
uintuintValue=>uintValue,
222
+
ulongulongValue=>checked((long)ulongValue),
223
+
decimaldecimalValue=>(long)decimalValue,
224
+
boolboolValue=>boolValue?1:0,
225
+
_ =>(long)value,
226
+
};
267
227
}
268
228
269
229
publicushortGetUInt16(intordinal)
270
230
{
271
231
varvalue=GetValue(ordinal);
272
-
if(valueisushort)
273
-
return(ushort)value;
274
-
275
-
if(valueissbyte)
276
-
returnchecked((ushort)(sbyte)value);
277
-
if(valueisbyte)
278
-
return(byte)value;
279
-
if(valueisshort)
280
-
returnchecked((ushort)(short)value);
281
-
if(valueisint)
282
-
returnchecked((ushort)(int)value);
283
-
if(valueisuint)
284
-
returnchecked((ushort)(uint)value);
285
-
if(valueislong)
286
-
returnchecked((ushort)(long)value);
287
-
if(valueisulong)
288
-
returnchecked((ushort)(ulong)value);
289
-
if(valueisdecimal)
290
-
return(ushort)(decimal)value;
291
-
if(valueisbool)
292
-
return(bool)value?(ushort)1:(ushort)0;
293
-
return(ushort)value;
232
+
returnvalueswitch
233
+
{
234
+
ushortushortValue=>ushortValue,
235
+
sbytesbyteValue=>checked((ushort)sbyteValue),
236
+
bytebyteValue=>byteValue,
237
+
shortshortValue=>checked((ushort)shortValue),
238
+
intintValue=>checked((ushort)intValue),
239
+
uintuintValue=>checked((ushort)uintValue),
240
+
longlongValue=>checked((ushort)longValue),
241
+
ulongulongValue=>checked((ushort)ulongValue),
242
+
decimaldecimalValue=>(ushort)decimalValue,
243
+
boolboolValue=>boolValue?(ushort)1:(ushort)0,
244
+
_ =>(ushort)value,
245
+
};
294
246
}
295
247
296
248
publicuintGetUInt32(intordinal)
297
249
{
298
250
varvalue=GetValue(ordinal);
299
-
if(valueisuint)
300
-
return(uint)value;
301
-
302
-
if(valueissbyte)
303
-
returnchecked((uint)(sbyte)value);
304
-
if(valueisbyte)
305
-
return(byte)value;
306
-
if(valueisshort)
307
-
returnchecked((uint)(short)value);
308
-
if(valueisushort)
309
-
return(ushort)value;
310
-
if(valueisint)
311
-
returnchecked((uint)(int)value);
312
-
if(valueislong)
313
-
returnchecked((uint)(long)value);
314
-
if(valueisulong)
315
-
returnchecked((uint)(ulong)value);
316
-
if(valueisdecimal)
317
-
return(uint)(decimal)value;
318
-
if(valueisbool)
319
-
return(bool)value?1u:0;
320
-
return(uint)value;
251
+
returnvalueswitch
252
+
{
253
+
uintuintValue=>uintValue,
254
+
sbytesbyteValue=>checked((uint)sbyteValue),
255
+
bytebyteValue=>byteValue,
256
+
shortshortValue=>checked((uint)shortValue),
257
+
ushortushortValue=>ushortValue,
258
+
intintValue=>checked((uint)intValue),
259
+
longlongValue=>checked((uint)longValue),
260
+
ulongulongValue=>checked((uint)ulongValue),
261
+
decimaldecimalValue=>(uint)decimalValue,
262
+
boolboolValue=>boolValue?1u:0,
263
+
_ =>(uint)value,
264
+
};
321
265
}
322
266
323
267
publiculongGetUInt64(intordinal)
324
268
{
325
269
varvalue=GetValue(ordinal);
326
-
if(valueisulong)
327
-
return(ulong)value;
328
-
329
-
if(valueissbyte)
330
-
returnchecked((ulong)(sbyte)value);
331
-
if(valueisbyte)
332
-
return(byte)value;
333
-
if(valueisshort)
334
-
returnchecked((ulong)(short)value);
335
-
if(valueisushort)
336
-
return(ushort)value;
337
-
if(valueisint)
338
-
returnchecked((ulong)(int)value);
339
-
if(valueisuint)
340
-
return(uint)value;
341
-
if(valueislong)
342
-
returnchecked((ulong)(long)value);
343
-
if(valueisdecimal)
344
-
return(ulong)(decimal)value;
345
-
if(valueisbool)
346
-
return(bool)value?1ul:0;
347
-
return(ulong)value;
270
+
returnvalueswitch
271
+
{
272
+
ulongulongValue=>ulongValue,
273
+
sbytesbyteValue=>checked((ulong)sbyteValue),
274
+
bytebyteValue=>byteValue,
275
+
shortshortValue=>checked((ulong)shortValue),
276
+
ushortushortValue=>ushortValue,
277
+
intintValue=>checked((ulong)intValue),
278
+
uintuintValue=>uintValue,
279
+
longlongValue=>checked((ulong)longValue),
280
+
decimaldecimalValue=>(ulong)decimalValue,
281
+
boolboolValue=>boolValue?1ul:0,
282
+
_ =>(ulong)value,
283
+
};
348
284
}
349
285
350
286
publicDateTimeGetDateTime(intordinal)
@@ -380,44 +316,37 @@ public Stream GetStream(int ordinal)
380
316
publicdecimalGetDecimal(intordinal)
381
317
{
382
318
varvalue=GetValue(ordinal);
383
-
if(valueisdecimal)// happy flow
384
-
return(decimal)value;
385
-
386
-
if(valueisdoubledoubleValue)
387
-
return(decimal)doubleValue;
388
-
389
-
if(valueisfloatfloatValue)
390
-
return(decimal)floatValue;
391
-
392
-
return(decimal)value;
319
+
returnvalueswitch
320
+
{
321
+
decimaldecimalValue=>decimalValue,
322
+
doubledoubleValue=>(decimal)doubleValue,
323
+
floatfloatValue=>(decimal)floatValue,
324
+
_ =>(decimal)value,
325
+
};
393
326
}
394
327
395
328
publicdoubleGetDouble(intordinal)
396
329
{
397
330
varvalue=GetValue(ordinal);
398
-
if(valueisdouble)// happy flow
399
-
return(double)value;
400
-
401
-
if(valueisfloatfloatValue)
402
-
returnfloatValue;
403
-
404
-
if(valueisdecimaldecimalValue)
405
-
return(double)decimalValue;
406
-
407
-
return(double)value;
331
+
returnvalueswitch
332
+
{
333
+
doubledoubleValue=>doubleValue,
334
+
floatfloatValue=>floatValue,
335
+
decimaldecimalValue=>(double)decimalValue,
336
+
_ =>(double)value,
337
+
};
408
338
}
409
339
410
340
publicfloatGetFloat(intordinal)
411
341
{
412
-
varvalue=GetValue(ordinal);
413
-
if(valueisfloat)// happy flow
414
-
return(float)value;
415
-
416
342
// Loss of precision is expected, significant loss of information is not.
417
343
// Use explicit range checks to guard against that.
344
+
varvalue=GetValue(ordinal);
418
345
returnvalueswitch
419
346
{
420
-
doubledoubleValue=>doubleValueis>=float.MinValue and <=float.MaxValue?(float)doubleValue:thrownewInvalidCastException("The value cannot be safely cast to Single."),
347
+
floatfloatValue=>floatValue,
348
+
doubledoubleValuewhendoubleValueis>=float.MinValue and <=float.MaxValue=>(float)doubleValue,
349
+
double _ =>thrownewInvalidCastException("The value cannot be safely cast to Single."),
0 commit comments