Repository navigation
Conversation
|
Important Review skippedBot user detected. To trigger a single review, invoke the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Co-authored-by: twogood <189982+twogood@users.noreply.github.com>
[BindMany] to run a [SqlUpdate] once per item of an IEnumerable parameter
There was a problem hiding this comment.
🟡 Changes recommended
Collection validation and runtime-type reflection violate the declared binding contract, and the README example duplicates a method.
2 open findings
What changed in this PR
Adds declarative batch execution for [SqlUpdate] DAO methods using [BindMany].
Changes:
- Builds one parameter set per collection item.
- Extends gateways with
ExecuteManyAsync. - Adds Dapper transaction tests and documentation.
| File | Description |
|---|---|
README.md |
Documents batch inserts. |
MethodHandler.cs |
Validates and expands [BindMany] arguments. |
IDatabaseGateway.cs |
Adds the batch execution contract. |
BindManyAttribute.cs |
Defines the new parameter attribute. |
DapperGatewayTransactionTest.cs |
Tests commit and rollback behavior. |
DapperGateway.cs |
Executes and totals repeated updates. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
@copilot NOT OK: "DapperGateway |
…sync Co-authored-by: twogood <189982+twogood@users.noreply.github.com>
Updated |
Removed duplicate InsertMany method declaration. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: David Eriksson <david@activout.se>
…perties Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@claude[agent] review |
twogood
left a comment
There was a problem hiding this comment.
Three findings from my review are attached inline.
| { | ||
| if (!names.Add(parameter.Name)) | ||
| { | ||
| throw new NotSupportedException($"Overlapping binding '{parameter.Name}' ({_method.Name})."); |
There was a problem hiding this comment.
Must fix: This global duplicate check breaks existing [BindProperties] callers even when the documented parameter_property aliases make the SQL unambiguous. For example, Insert([BindProperties] User first, [BindProperties] User second) with SQL using only @first_id and @second_Name succeeds on the base commit but now throws NotSupportedException: Overlapping binding 'id'. Please remove this check from AddSqlStatementParameters; keep any new collision policy scoped to [BindMany].
| } | ||
|
|
||
| var task = _gateway.ExecuteManyAsync(statement, sets); | ||
| return _isAsync ? task : task.Result; |
There was a problem hiding this comment.
Should fix: The new batch tests only declare Task<int>, while this returns the raw Task<int> for every async batch update. Please add one [BindMany] DAO method returning plain Task and assert that its rows are inserted. This covers the return form requested by #62 and guards the DispatchProxy assignability behavior.
|
|
||
| // Executes the statement once per item, using the item's properties | ||
| [SqlUpdate("INSERT INTO user(id, name) VALUES (@id, @Name)")] | ||
| Task<int> InsertMany([BindMany] IEnumerable<User> users); |
There was a problem hiding this comment.
Should fix: Please state here that batch execution is not atomic unless the caller supplies a transaction. If item two fails after item one succeeds, item one remains committed; the example currently makes that easy to miss.


A DAO method builds a single
SqlStatement, so there is no equivalent of Dapper'sExecuteAsync(sql, IEnumerable<object>, transaction). Callers have to issue one DAO call per item.[BindMany]attributeIEnumerable<T>parameter of a[SqlUpdate]method.[BindProperties]:propandparam_prop, honouring[Bind].NotSupportedException: non-update method, more than one[BindMany], non-enumerable type, or combined with[BindProperties].nullcollection or anullitem throws.IDatabaseGateway.ExecuteManyAsync(statement, parameterSets)DapperGatewayExecuteAsyncper parameter set instatement.Transaction.DynamicParameters.Review notes:
@Namefor aNameproperty. This is the same as[BindProperties]today.[BindMany]insert inDapperGatewayTransactionTest.README.mdhas a new example.