Repository navigation
Pass transactions per call instead of storing them on DapperGateway - #57
Conversation
DAO methods take an IDbTransaction parameter, which MethodHandler passes to the gateway on the SqlStatement. DAO interfaces can extend IWithTransactions to begin transactions without access to the connection. The gateway holds no transaction state. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (7)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. WalkthroughThe database client now exposes transaction creation through DAO methods, carries an optional transaction on each SQL statement, and passes that transaction to Dapper execution. Transaction parameters are excluded from SQL parameter binding. Tests and README examples use the DAO-level transaction flow. ChangesDAO Transaction Flow
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant DAO
participant DatabaseClient
participant MethodHandler
participant DapperGateway
participant Dapper
DAO->>DatabaseClient: BeginTransaction(isolationLevel)
DatabaseClient->>DapperGateway: BeginTransaction(isolationLevel)
DapperGateway-->>DAO: Return IDbTransaction
DAO->>DatabaseClient: Invoke SQL method with transaction
DatabaseClient->>MethodHandler: Invoke method handler
MethodHandler->>DapperGateway: Send SqlStatement with transaction
DapperGateway->>Dapper: Execute with statement transaction
Dapper-->>DAO: Return result
Merge Risk: ⚪ Minimal · up to This change moves transactions from gateway state to per-call parameters and adds a way to begin a transaction from a DAO. Commit and rollback are tested. The removal of the old gateway property is an intentional breaking change, and no merge-blocking risk was found. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 6 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. A rabbit begins a transaction with care, Comment |
There was a problem hiding this comment.
🟢 Approval recommended
Transaction forwarding is consistent across execution paths, with only optional single-row regression coverage remaining.
0 open findings
What changed in this PR
Replaces gateway-level transaction state with per-call transactions and lets DAOs begin transactions directly.
Changes:
- Adds transaction creation through
IWithTransactions. - Routes transaction arguments separately from SQL parameters.
- Updates documentation and commit/rollback tests.
| File | Description |
|---|---|
| README.md | Documents per-call transactions. |
| Activout.DatabaseClient/IWithTransactions.cs | Adds the DAO transaction interface. |
| Activout.DatabaseClient/Implementation/MethodHandler.cs | Extracts transaction arguments from SQL parameters. |
| Activout.DatabaseClient/Implementation/DatabaseClient.cs | Routes transaction creation to the gateway. |
| Activout.DatabaseClient/IDatabaseGateway.cs | Adds transaction creation and statement transaction data. |
| Activout.DatabaseClient.Test/DapperGatewayTransactionTest.cs | Tests DAO-driven commit and rollback. |
| Activout.DatabaseClient.Dapper/DapperGateway.cs | Forwards statement transactions to Dapper. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Replaces the settable
DapperGateway.Transactionfrom #54, which had to be set and cleared by hand, could mismatch the gateway's connection, and wasn't reachable when the gateway was created inline (as in the README's DI example).IDbTransactionparameter.MethodHandlerpasses it to the gateway onSqlStatement.Transactionand doesn't bind it as a SQL parameter. Passingnullmeans no transaction.IWithTransactionsinterface: DAO interfaces can extend it to callBeginTransaction(), so callers don't need the connection. Backed by the newIDatabaseGateway.BeginTransaction.DapperGatewayno longer stores any transaction.Breaking change compared with v5.0.0-rc3: the
DapperGateway.Transactionproperty is removed, andIDatabaseGatewayhas a new member.Tested:
dotnet test(19 passed), including commit and rollback through the DAO on Sqlite.🤖 Generated with Claude Code
Summary by CodeRabbit