Repository navigation
AspNetCore Command Transactions
Register the command unit-of-work bundle around command routes, then supply transactional resources through Providers.
Register [PartieSystemBundle] on a route or an enclosing group:
[BrigadeGroup("/api/v1")]
[AspNetSystemBundle]
[PartieSystemBundle]
[ExpoSystemBundle]
public static partial class ApiRoutes
{
...
}The core bundle contains UnitOfWorkPartie. Commands receive the resulting UnitOfWork as the first handler argument. Queries do not receive a unit of work through this command contract.
Putting Expo after the core bundle makes validation run inside the command boundary. The outer HTTP bundle maps the result after transaction handling has completed.
A Mise database bundle supplies command transactions and a writer that uses them. Register it inside the system bundles' scope:
[BrigadeGroup("/courses")]
[MisePostgreSqlBundle("CourseDatabase")]
private static partial class Courses
{
[CourseUpdateHandlerRoute.Put("/{courseId}")]
public static partial void Update();
}The command handler requests the writer through its context:
public sealed record CourseUpdateContext([Provide] DbWriter Writer);Write through context.Writer and return your command result. Let UnitOfWorkPartie choose commit or rollback when the downstream pipeline returns. See Database access with Mise for a complete writer example.
See Unit of work for outcomes and resource enlistment.
- Home
- Getting started
-
Package guides
- Partie
- Expo
-
Mise
- Database setup
- Table mappings
- Aliases
- Relationships
- Result rows
- SQL interpolation
- Queries
- Filtering
- Joins
- Aggregation
- Paging and ordering
- Subqueries
- Set operations
- Common table expressions
- Readers
- Streaming
- Writers
- Inserts
- Updates
- Deletes
- Returned rows
- Custom SQL and procedures
- Transactions
- Resource lifetimes
- Database dialects
- Diagnostics
- Integrations
- Recipes
- Reference
- Troubleshooting
- Development