DapperAOT icon indicating copy to clipboard operation
DapperAOT copied to clipboard

Support Dapper overloads with CommandDefinition

Open batwad opened this issue 2 years ago • 4 comments

I am using the Dapper overloads which accept a CommandDefinition because I want to pass CancellationToken, for example:

        var result = await conn.ExecuteScalarAsync<string>(new CommandDefinition("sp_CrunchNumbers",
            new
            {
                WarpFactor = 43
            },
            commandType: CommandType.StoredProcedure,
            cancellationToken: cancellationToken));

The analyzer doesn't seem to detect this usage and generate code.

If I change to the overload which takes multiple args then it does generate code, however this doesn't support CancellationToken.

        var result = await conn.ExecuteScalarAsync<string>("sp_CrunchNumbers",
            new
            {
                WarpFactor = 43
            },
            commandType: CommandType.StoredProcedure);

batwad avatar Feb 03 '24 20:02 batwad

I was going crazy trying to figure out why no code was generated then I found this issue...

Are there any technical issues to implement this feature?

giammin avatar Mar 28 '25 08:03 giammin

Sorry, did not find time for that yet. Will try to prioritize that :)

DeagleGross avatar Mar 28 '25 14:03 DeagleGross

@DeagleGross, I see that the PR was created a few months ago. Are there any blockers preventing it from being merged? Do you need any help?

goremykin avatar Jul 29 '25 07:07 goremykin

@goremykin there are some changes to be made, but it's up to Marc to review and merge changes once they are of a good quality.

DeagleGross avatar Jul 29 '25 07:07 DeagleGross