Skip to content

Add CancellationToken support to QueryAsync overload #2138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dapper/PublicAPI.Shipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ static Dapper.SqlMapper.QueryAsync<TFirst, TSecond, TThird, TFourth, TReturn>(th
static Dapper.SqlMapper.QueryAsync<TFirst, TSecond, TThird, TFourth, TReturn>(this System.Data.IDbConnection! cnn, string! sql, System.Func<TFirst, TSecond, TThird, TFourth, TReturn>! map, object? param = null, System.Data.IDbTransaction? transaction = null, bool buffered = true, string! splitOn = "Id", int? commandTimeout = null, System.Data.CommandType? commandType = null) -> System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<TReturn>!>!
static Dapper.SqlMapper.QueryAsync<TFirst, TSecond, TThird, TReturn>(this System.Data.IDbConnection! cnn, Dapper.CommandDefinition command, System.Func<TFirst, TSecond, TThird, TReturn>! map, string! splitOn = "Id") -> System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<TReturn>!>!
static Dapper.SqlMapper.QueryAsync<TFirst, TSecond, TThird, TReturn>(this System.Data.IDbConnection! cnn, string! sql, System.Func<TFirst, TSecond, TThird, TReturn>! map, object? param = null, System.Data.IDbTransaction? transaction = null, bool buffered = true, string! splitOn = "Id", int? commandTimeout = null, System.Data.CommandType? commandType = null) -> System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<TReturn>!>!
static Dapper.SqlMapper.QueryAsync<TReturn>(this System.Data.IDbConnection! cnn, string! sql, System.Type![]! types, System.Func<object![]!, TReturn>! map, object? param = null, System.Data.IDbTransaction? transaction = null, bool buffered = true, string! splitOn = "Id", int? commandTimeout = null, System.Data.CommandType? commandType = null) -> System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<TReturn>!>!
static Dapper.SqlMapper.QueryAsync<TReturn>(this System.Data.IDbConnection! cnn, string! sql, System.Type![]! types, System.Func<object![]!, TReturn>! map, object? param = null, System.Data.IDbTransaction? transaction = null, bool buffered = true, string! splitOn = "Id", int? commandTimeout = null, System.Data.CommandType? commandType = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<TReturn>!>!
static Dapper.SqlMapper.QueryCachePurged -> System.EventHandler?
static Dapper.SqlMapper.QueryFirst(this System.Data.IDbConnection! cnn, string! sql, object? param = null, System.Data.IDbTransaction? transaction = null, int? commandTimeout = null, System.Data.CommandType? commandType = null) -> dynamic!
static Dapper.SqlMapper.QueryFirst(this System.Data.IDbConnection! cnn, System.Type! type, string! sql, object? param = null, System.Data.IDbTransaction? transaction = null, int? commandTimeout = null, System.Data.CommandType? commandType = null) -> object!
Expand Down
5 changes: 3 additions & 2 deletions Dapper/SqlMapper.Async.cs
Original file line number Diff line number Diff line change
Expand Up @@ -963,11 +963,12 @@ private static async Task<IEnumerable<TReturn>> MultiMapAsync<TFirst, TSecond, T
/// <param name="splitOn">The field we should split and read the second object from (default: "Id").</param>
/// <param name="commandTimeout">Number of seconds before command execution timeout.</param>
/// <param name="commandType">Is it a stored proc or a batch?</param>
/// <param name="cancellationToken">The cancellation token for this command.</param>
/// <returns>An enumerable of <typeparamref name="TReturn"/>.</returns>
[System.Diagnostics.CodeAnalysis.SuppressMessage("ApiDesign", "RS0026:Do not add multiple public overloads with optional parameters", Justification = "Grandfathered")]
public static Task<IEnumerable<TReturn>> QueryAsync<TReturn>(this IDbConnection cnn, string sql, Type[] types, Func<object[], TReturn> map, object? param = null, IDbTransaction? transaction = null, bool buffered = true, string splitOn = "Id", int? commandTimeout = null, CommandType? commandType = null)
public static Task<IEnumerable<TReturn>> QueryAsync<TReturn>(this IDbConnection cnn, string sql, Type[] types, Func<object[], TReturn> map, object? param = null, IDbTransaction? transaction = null, bool buffered = true, string splitOn = "Id", int? commandTimeout = null, CommandType? commandType = null, CancellationToken cancellationToken = default)
{
var command = new CommandDefinition(sql, param, transaction, commandTimeout, commandType, buffered ? CommandFlags.Buffered : CommandFlags.None, default);
var command = new CommandDefinition(sql, param, transaction, commandTimeout, commandType, buffered ? CommandFlags.Buffered : CommandFlags.None, cancellationToken);
return MultiMapAsync(cnn, command, types, map, splitOn);
}

Expand Down