diff --git a/Base/Base.csproj.DotSettings b/Base/Base.csproj.DotSettings new file mode 100644 index 0000000..89316e4 --- /dev/null +++ b/Base/Base.csproj.DotSettings @@ -0,0 +1,2 @@ + + Library \ No newline at end of file diff --git a/Base/Structures/DbDataReaderMaybeExtensions.cs b/Base/Structures/DbDataReaderMaybeExtensions.cs index 342d893..a063462 100644 --- a/Base/Structures/DbDataReaderMaybeExtensions.cs +++ b/Base/Structures/DbDataReaderMaybeExtensions.cs @@ -7,48 +7,74 @@ namespace FruityFoundation.Base.Structures; public static class DbDataReaderMaybeExtensions { - public static async Task> TryGetBooleanAsync(this DbDataReader reader, int ord, CancellationToken cancellationToken = default) => - await TryGetAsync(reader, ord, reader.GetBoolean, cancellationToken); + public static async Task> TryGetBooleanAsync(this DbDataReader reader, int ord, + CancellationToken cancellationToken = default) => + await TryGetAsync(reader, ord, reader.GetBoolean, cancellationToken).ConfigureAwait(continueOnCapturedContext: false); - public static async Task> TryGetByteAsync(this DbDataReader reader, int ord, CancellationToken cancellationToken = default) => - await TryGetAsync(reader, ord, reader.GetByte, cancellationToken); + public static async Task> TryGetByteAsync(this DbDataReader reader, int ord, + CancellationToken cancellationToken = default) => + await TryGetAsync(reader, ord, reader.GetByte, cancellationToken) + .ConfigureAwait(continueOnCapturedContext: false); - public static async Task> TryGetBytesAsync(this DbDataReader reader, int ord, long fieldOffset, byte[]? buffer, int bufferOffset, int length, CancellationToken cancellationToken = default) => - await TryGetAsync(reader, ord, _ => reader.GetBytes(ord, fieldOffset, buffer, bufferOffset, length), cancellationToken); + public static async Task> TryGetBytesAsync(this DbDataReader reader, int ord, long fieldOffset, + byte[]? buffer, int bufferOffset, int length, CancellationToken cancellationToken = default) => + await TryGetAsync(reader, ord, _ => reader.GetBytes(ord, fieldOffset, buffer, bufferOffset, length), + cancellationToken).ConfigureAwait(continueOnCapturedContext: false); - public static async Task> TryGetCharAsync(this DbDataReader reader, int ord, CancellationToken cancellationToken = default) => - await TryGetAsync(reader, ord, reader.GetChar, cancellationToken); + public static async Task> TryGetCharAsync(this DbDataReader reader, int ord, + CancellationToken cancellationToken = default) => + await TryGetAsync(reader, ord, reader.GetChar, cancellationToken) + .ConfigureAwait(continueOnCapturedContext: false); - public static async Task> TryGetCharsAsync(this DbDataReader reader, int ord, long fieldOffset, char[]? buffer, int bufferOffset, int length, CancellationToken cancellationToken = default) => - await TryGetAsync(reader, ord, _ => reader.GetChars(ord, fieldOffset, buffer, bufferOffset, length), cancellationToken); + public static async Task> TryGetCharsAsync(this DbDataReader reader, int ord, long fieldOffset, + char[]? buffer, int bufferOffset, int length, CancellationToken cancellationToken = default) => + await TryGetAsync(reader, ord, _ => reader.GetChars(ord, fieldOffset, buffer, bufferOffset, length), + cancellationToken).ConfigureAwait(continueOnCapturedContext: false); - public static async Task> TryGetDateTimeAsync(this DbDataReader reader, int ord, CancellationToken cancellationToken = default) => - await TryGetAsync(reader, ord, reader.GetDateTime, cancellationToken); + public static async Task> TryGetDateTimeAsync(this DbDataReader reader, int ord, + CancellationToken cancellationToken = default) => + await TryGetAsync(reader, ord, reader.GetDateTime, cancellationToken) + .ConfigureAwait(continueOnCapturedContext: false); - public static async Task> TryGetDecimalAsync(this DbDataReader reader, int ord, CancellationToken cancellationToken = default) => - await TryGetAsync(reader, ord, reader.GetDecimal, cancellationToken); + public static async Task> TryGetDecimalAsync(this DbDataReader reader, int ord, + CancellationToken cancellationToken = default) => + await TryGetAsync(reader, ord, reader.GetDecimal, cancellationToken) + .ConfigureAwait(continueOnCapturedContext: false); - public static async Task> TryGetFloatAsync(this DbDataReader reader, int ord, CancellationToken cancellationToken = default) => - await TryGetAsync(reader, ord, reader.GetFloat, cancellationToken); + public static async Task> TryGetFloatAsync(this DbDataReader reader, int ord, + CancellationToken cancellationToken = default) => + await TryGetAsync(reader, ord, reader.GetFloat, cancellationToken) + .ConfigureAwait(continueOnCapturedContext: false); - public static async Task> TryGetGuidAsync(this DbDataReader reader, int ord, CancellationToken cancellationToken = default) => - await TryGetAsync(reader, ord, reader.GetGuid, cancellationToken); + public static async Task> TryGetGuidAsync(this DbDataReader reader, int ord, + CancellationToken cancellationToken = default) => + await TryGetAsync(reader, ord, reader.GetGuid, cancellationToken) + .ConfigureAwait(continueOnCapturedContext: false); - public static async Task> TryGetInt16Async(this DbDataReader reader, int ord, CancellationToken cancellationToken = default) => - await TryGetAsync(reader, ord, reader.GetInt16, cancellationToken); + public static async Task> TryGetInt16Async(this DbDataReader reader, int ord, + CancellationToken cancellationToken = default) => + await TryGetAsync(reader, ord, reader.GetInt16, cancellationToken) + .ConfigureAwait(continueOnCapturedContext: false); - public static async Task> TryGetInt32Async(this DbDataReader reader, int ord, CancellationToken cancellationToken = default) => - await TryGetAsync(reader, ord, reader.GetInt32, cancellationToken); + public static async Task> TryGetInt32Async(this DbDataReader reader, int ord, + CancellationToken cancellationToken = default) => + await TryGetAsync(reader, ord, reader.GetInt32, cancellationToken) + .ConfigureAwait(continueOnCapturedContext: false); - public static async Task> TryGetInt64Async(this DbDataReader reader, int ord, CancellationToken cancellationToken = default) => - await TryGetAsync(reader, ord, reader.GetInt64, cancellationToken); + public static async Task> TryGetInt64Async(this DbDataReader reader, int ord, + CancellationToken cancellationToken = default) => + await TryGetAsync(reader, ord, reader.GetInt64, cancellationToken) + .ConfigureAwait(continueOnCapturedContext: false); - public static async Task> TryGetStringAsync(this DbDataReader reader, int ord, CancellationToken cancellationToken = default) => - await TryGetAsync(reader, ord, reader.GetString, cancellationToken); + public static async Task> TryGetStringAsync(this DbDataReader reader, int ord, + CancellationToken cancellationToken = default) => + await TryGetAsync(reader, ord, reader.GetString, cancellationToken) + .ConfigureAwait(continueOnCapturedContext: false); - private static async Task> TryGetAsync(DbDataReader reader, int ord, Func valueGetter, CancellationToken cancellationToken) + private static async Task> TryGetAsync(DbDataReader reader, int ord, Func valueGetter, + CancellationToken cancellationToken) { - if (await reader.IsDBNullAsync(ord, cancellationToken)) + if (await reader.IsDBNullAsync(ord, cancellationToken).ConfigureAwait(continueOnCapturedContext: false)) return Maybe.Empty(); var value = valueGetter(ord);