Table of Contents

Class BatchExtensions

Namespace
NextORM.Core
Assembly
nextorm.core.dll

Entry point for executing several statements as one batch (one round trip, one server session). A batch is useful when a statement depends on a session-scoped side effect of an earlier one — a materialisation (CREATE TEMPORARY TABLE ... AS SELECT) or a DML statement (INSERT, UPDATE, DELETE) followed by a query reading the result: under a connection-level pooler that reassigns the backend per transaction (PgBouncer in transaction mode) two separate commands can be routed to different backends, so the read fails with relation does not exist. One batch keeps them on the same backend.

A provider capable of a single-round-trip batch opts in through SupportsBatch (PostgreSQL, SQL Server, MySQL, MariaDB and SQLite). The in-memory context has no batch executor, so CreateBatchBuilder(IDataContext) rejects it immediately; a database-backed provider without the capability throws NotSupportedException when the batch renders instead of silently degrading to separate statements.

public static class BatchExtensions
Inheritance
BatchExtensions
Inherited Members

Examples

var rows = ctx.CreateBatchBuilder()
    .Update(ctx.CreateUpdateBuilder<Order>().Set(o => o.Status, "shipped").Where(o => o.Id == id))
    .Query(ctx.From<Order>().Where(o => o.Id == id).Select(o => new { o.Id, o.Status }))
    .ToList();

Methods

CreateBatchBuilder(IDataContext)

Starts a batch on a database-backed context.

public static BatchBuilder CreateBatchBuilder(this IDataContext context)

Parameters

context IDataContext

The context that executes the batch.

Returns

BatchBuilder

A builder for the batch's statements.

Exceptions

NotSupportedException

The context cannot execute batches (the in-memory context).