var builder = WebApplication.CreateBuilder(args);
builder.Services.AddXtraqDbContext(options =>
{
options.ConnectionString = builder.Configuration.GetConnectionString("DefaultConnection")
?? throw new InvalidOperationException("Missing 'DefaultConnection'.");
});
var app = builder.Build();
SessionSettings applies SQL Server SET flags right after opening a connection. Standard default: QUOTED_IDENTIFIER, ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, CONCAT_NULL_YIELDS_NULL, ARITHABORT, NOCOUNT ON; NUMERIC_ROUNDABORT OFF. Override if needed:
builder.Services.AddXtraqDbContext(options =>
{
options.ConnectionString = "...";
options.SessionSettings.Clear()
.WithQuotedIdentifierOn()
.WithAnsiNullsOn()
.WithAnsiPaddingOn()
.WithAnsiWarningsOn()
.WithConcatNullYieldsNull()
.WithArithAbortOn()
.WithNoCountOn()
.WithNumericRoundAbortOff();
});
app.MapPost("/orders", async (
OrderCreateInput input,
IXtraqDbContext db,
CancellationToken ct) =>
{
var result = await db.ConfigureProcedure(input)
.ExecuteAsync(ctx => ctx.OrderCreateAsync, ct);
return Results.Ok(result);
});
.WithTransaction() to wrap execution in the generated transaction scope..WithPolicy(...) for retries/telemetry wrappers.ConfigureProcedure<TRequest, TInput>(request, mapper) when you accept request DTOs and need the generated mapper.ConfigureProcedureStream) expose the same pattern for NDJSON or server-sent streams.Configuration & Environment Bootstrap
The xtraq CLI keeps project settings deterministic by committing a `.xtraqconfig` file and limiting the local `.env` to secrets plus logging toggles. CLI flags can still override behaviour when required, while process-level environment variables are now restricted to connection strings and diagnostic switches so the tracked JSON snapshot remains authoritative.
Parameter Binding
Enable automatic parameter hydration for generated procedures with minimal setup.