Files
Dapper/benchmarks/Dapper.Tests.Performance/SqlDataReaderHelper.cs
Marc Gravell bd4f75b512 normalize async API surface over all TFMs (#2144)
* - normalize async API surface over all TFMs (fix #2143)
- target net8.0 instead of net5.0
- lib updates

* net9 SDK

* perf tests: clean up SqlClient warning

* CI fix: test concurrency

* rev snowflake
2025-02-06 12:11:30 +00:00

32 lines
904 B
C#

using System;
using Microsoft.Data.SqlClient;
using System.Runtime.CompilerServices;
namespace Dapper.Tests.Performance
{
public static class SqlDataReaderHelper
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string GetNullableString(this SqlDataReader reader, int index)
{
object tmp = reader.GetValue(index);
if (tmp != DBNull.Value)
{
return (string)tmp;
}
return null;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T? GetNullableValue<T>(this SqlDataReader reader, int index) where T : struct
{
object tmp = reader.GetValue(index);
if (tmp != DBNull.Value)
{
return (T)tmp;
}
return null;
}
}
}