Drizin / InterpolatedSql

Sql Builder using Interpolated Strings
MIT License
106 stars 7 forks source link

CancellationToken support #13

Closed terryaney closed 6 months ago

terryaney commented 6 months ago

Added CancellationToken support. I tagged you in a couple of tweets to Marc Gravell that you probably saw. From what I understand, adding the optional CancellationToken parameter shouldn't break any existing compatibility, but maybe you know as well. Maintaining open source compatibility is a new realm for me :)

Additionally, I submitted a pr to Dapper to enable support on the following overload (currently, I just disregard the CancellationToken):

        public static Task<IEnumerable<TReturn>> QueryAsync<TReturn>(this IDapperSqlCommand command, Type[] types, Func<object[], TReturn> map, IDbTransaction? transaction = null, bool buffered = true, string splitOn = "Id", int? commandTimeout = null, CommandType? commandType = null, CancellationToken cancellationToken = default)
        {
            return command.DbConnection.QueryAsync<TReturn>(sql: command.Sql, param: ParametersDictionary.LoadFrom(command), transaction: transaction, commandTimeout: commandTimeout, commandType: commandType, buffered: buffered, types: types, map: map, splitOn: splitOn);
            // return command.DbConnection.QueryAsync<TReturn>(command: new CommandDefinition(commandText: command.Sql, parameters: ParametersDictionary.LoadFrom(command), transaction: transaction, commandTimeout: commandTimeout, commandType: commandType, flags: buffered ? CommandFlags.Buffered : CommandFlags.None, cancellationToken: cancellationToken), types: types, map: map, splitOn: splitOn);
        }
Drizin commented 6 months ago

Looks good, thanks! Republished as 2.2.0