Skip to content

AspNetCore Bundles

SteffenBlake edited this page Sep 28, 2026 · 1 revision

ASP.NET Core bundles

Register system bundles on the root route group and database bundles on the groups that use them. See Partie bundles for member ordering and parameter forwarding.

Built-in system bundles

For an ASP.NET Core API, register HTTP mapping before command unit-of-work handling:

[BrigadeGroup("/api/v1")]
[AspNetSystemBundle]
[PartieSystemBundle]
[ExpoSystemBundle]
public static partial class ApiRoutes
{
    ...
}

[AspNetSystemBundle] comes from Brigade.Net.Partie.AspNetCore and contains HttpResultPartie. [PartieSystemBundle] comes from Brigade.Net.Partie and contains UnitOfWorkPartie. [ExpoSystemBundle] comes from Brigade.Net.Partie.Extensions.Expo and contains request validation.

This order lets HTTP mapping see downstream failures and places validation inside the command unit of work. Add Expo's packages before using its bundle; see Validation with Expo.

Database bundles

Register a database bundle on the group or route that uses its named connection:

[BrigadeGroup("/courses")]
[MisePostgreSqlBundle("CourseDatabase")]
private static partial class Courses
{
    ...
}

Place this group inside the root group above. The bundle supplies named configuration, query readers, command transactions, and command writers. Providers run when their outputs are needed.

The integration namespaces and bundle attributes are:

Namespace Attribute
Brigade.Net.Partie.Extensions.Mise.SqlServer [MiseSqlServerBundle(name)]
Brigade.Net.Partie.Extensions.Mise.PostgreSQL [MisePostgreSqlBundle(name)]
Brigade.Net.Partie.Extensions.Mise.SQLite [MiseSqliteBundle(name)]
Brigade.Net.Partie.Extensions.Mise.MySQL [MiseMySqlBundle(name)]
Brigade.Net.Partie.Extensions.Mise.MariaDb [MiseMariaDbBundle(name)]

See Database access with Mise for packages, connection strings, and consuming readers and writers.

Define an application bundle

Use the real step or nested bundle types as constructor parameters:

// ApiBundle.cs
public sealed record ApiBundle<TRequest, TResult>(
    Brigade.Net.Partie.AspNetCore.AspNetSystemBundle<TRequest, TResult> Http,
    PartieSystemBundle<TRequest, TResult> Transactions,
    QueryTimingPartie<TRequest, TResult> Timing
);

QueryTimingPartie is defined in Generic matching. Register the generated attribute:

[BrigadeGroup("/api/v1")]
[ApiBundle]
public static partial class ApiRoutes
{
    ...
}

The bundle expands in place. Its timing step matches queries; the unit-of-work step matches commands. Member constraints, Provider laziness, and context value selection still apply.

See Routes and groups for registration scope.

Clone this wiki locally