DapperLib / DapperLib/Dapper

Add CancellationToken support for MultiMap Queries.

Open
#1,967 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
18.4k
Forks
3.7k
Avg merge
5h 8m
Merged PRs (30d)
1

Description

Add overload methods for MultiMap queries to pass CancellationToken to CommandDefinition.

From this:

public static IEnumerable<TReturn> Query<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)
{
    var command = new CommandDefinition(sql, param, transaction, commandTimeout, commandType, buffered ? CommandFlags.Buffered : CommandFlags.None);
    var results = MultiMapImpl(cnn, command, types, map, splitOn, null, null, true);
    return buffered ? results.ToList() : results;
}

To this:

public static IEnumerable<TReturn> Query<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 ct = CancellationToken.None)
{
    var command = new CommandDefinition(sql, param, transaction, commandTimeout, commandType, buffered ? CommandFlags.Buffered : CommandFlags.None, ct);
    var results = MultiMapImpl(cnn, command, types, map, splitOn, null, null, true);
    return buffered ? results.ToList() : results;
}

EDIT:

Another aproach would be to give access to some private methods like:
MultiMapImpl
where we could manually build CommandDefinition with CancellationToken assigned to it.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the MultiMap Query overload shown in the issue and trace how it calls MultiMapImpl and constructs CommandDefinition. Identify the related MultiMap overloads that need the same CancellationToken support; done means callers can pass a token through to CommandDefinition for these queries.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
databases
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.