feat: support Dapper overloads with CommandDefinition #153
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Current PR adds a support to parse use cases with
CommandDefinition
.Usage check
If an user invocation has 2 or more parameters which are 1)
cnn
; 2)command
where it is of typeCommandDefinition
, then I consider it to be a proper Dapper usage withCommandDefinition
.DapperAnalyzer has built-in argument processing to fix sql / detect buffering etc.
DapperAOT/src/Dapper.AOT.Analyzers/CodeAnalysis/DapperAnalyzer.cs
Lines 514 to 517 in 4f8cd50
Unfortunately, it is too complicated to cover many other usages of
CommandDefinition
, so I only added a case for in-place object creation:Other cases will work (i.e.
CommandDefinition
as local variable), but will not have argument processing done.Generator
Since the Dapper.AOT has its own API, it is very easy to just pass in the same parameters who are the
CommandDefinition
members. So I just do this for example:CommandDefinition
implementation is very convenient for such usage - for example I dont care what CancellationToken to pass in, because if it is not passed intoCommandDefinition
, it will be simply default. So I just map all members into the underlying SQL APITests
Added code-generation + integration tests.
Fixes #112