Commit ae0b3962 authored by Marc Gravell's avatar Marc Gravell

ConfigureAwait

parent 03fc8dee
...@@ -33,8 +33,8 @@ public static async Task<IEnumerable<T>> QueryAsync<T>(this IDbConnection cnn, C ...@@ -33,8 +33,8 @@ public static async Task<IEnumerable<T>> QueryAsync<T>(this IDbConnection cnn, C
{ {
try try
{ {
if (wasClosed) await ((DbConnection)cnn).OpenAsync(); if (wasClosed) await ((DbConnection)cnn).OpenAsync().ConfigureAwait(false);
using (var reader = await cmd.ExecuteReaderAsync(command.CancellationToken)) using (var reader = await cmd.ExecuteReaderAsync(command.CancellationToken).ConfigureAwait(false))
{ {
return ExecuteReader<T>(reader, identity, info).ToList(); return ExecuteReader<T>(reader, identity, info).ToList();
} }
...@@ -67,8 +67,8 @@ public static async Task<int> ExecuteAsync(this IDbConnection cnn, CommandDefini ...@@ -67,8 +67,8 @@ public static async Task<int> ExecuteAsync(this IDbConnection cnn, CommandDefini
{ {
try try
{ {
if (wasClosed) await ((DbConnection)cnn).OpenAsync(); if (wasClosed) await ((DbConnection)cnn).OpenAsync().ConfigureAwait(false);
return await cmd.ExecuteNonQueryAsync(command.CancellationToken); return await cmd.ExecuteNonQueryAsync(command.CancellationToken).ConfigureAwait(false);
} }
finally finally
{ {
...@@ -256,9 +256,9 @@ public static async Task<int> ExecuteAsync(this IDbConnection cnn, CommandDefini ...@@ -256,9 +256,9 @@ public static async Task<int> ExecuteAsync(this IDbConnection cnn, CommandDefini
bool wasClosed = cnn.State == ConnectionState.Closed; bool wasClosed = cnn.State == ConnectionState.Closed;
try try
{ {
if (wasClosed) await ((DbConnection)cnn).OpenAsync(); if (wasClosed) await ((DbConnection)cnn).OpenAsync().ConfigureAwait(false);
using (var cmd = (DbCommand)command.SetupCommand(cnn, info.ParamReader)) using (var cmd = (DbCommand)command.SetupCommand(cnn, info.ParamReader))
using (var reader = await cmd.ExecuteReaderAsync(command.CancellationToken)) using (var reader = await cmd.ExecuteReaderAsync(command.CancellationToken).ConfigureAwait(false))
{ {
var results = MultiMapImpl<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TReturn>(null, default(CommandDefinition), map, splitOn, reader, identity); var results = MultiMapImpl<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TReturn>(null, default(CommandDefinition), map, splitOn, reader, identity);
return command.Buffered ? results.ToList() : results; return command.Buffered ? results.ToList() : results;
...@@ -315,9 +315,9 @@ public static async Task<GridReader> QueryMultipleAsync(this IDbConnection cnn, ...@@ -315,9 +315,9 @@ public static async Task<GridReader> QueryMultipleAsync(this IDbConnection cnn,
bool wasClosed = cnn.State == ConnectionState.Closed; bool wasClosed = cnn.State == ConnectionState.Closed;
try try
{ {
if (wasClosed) await ((DbConnection)cnn).OpenAsync(); if (wasClosed) await ((DbConnection)cnn).OpenAsync().ConfigureAwait(false);
cmd = (DbCommand)command.SetupCommand(cnn, info.ParamReader); cmd = (DbCommand)command.SetupCommand(cnn, info.ParamReader);
reader = await cmd.ExecuteReaderAsync(wasClosed ? CommandBehavior.CloseConnection : CommandBehavior.Default, command.CancellationToken); reader = await cmd.ExecuteReaderAsync(wasClosed ? CommandBehavior.CloseConnection : CommandBehavior.Default, command.CancellationToken).ConfigureAwait(false);
var result = new GridReader(cmd, reader, identity); var result = new GridReader(cmd, reader, identity);
wasClosed = false; // *if* the connection was closed and we got this far, then we now have a reader wasClosed = false; // *if* the connection was closed and we got this far, then we now have a reader
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment