Table of Contents

Class UpdateJoinBuilder<TProjection>

Namespace
NextORM.Core
Assembly
nextorm.core.dll

Fluent builder for a multi-table UPDATE (the UPDATE ... FROM/join form), started with CreateUpdateJoinBuilder<T1, T2>(JoinedEntityBuilder<T1, T2>). The target is the first table of the join chain; the columns to write are supplied with Set(...), whose right-hand side may read any joined table. The rows to change are selected by the join and an optional Where(Expression<Func<TProjection, bool>>).

Only INNER joins are supported: the FROM/join form folds the join conditions into the WHERE, so an outer join would silently change which rows are updated. There is deliberately no change tracking — the terminal issues exactly one explicit command.

public sealed class UpdateJoinBuilder<TProjection>

Type Parameters

TProjection

The positional join projection (Projection<T1, ...>).

Inheritance
UpdateJoinBuilder<TProjection>
Inherited Members
Extension Methods

Methods

IgnoreFilters()

Disables all global query filters declared for the target (first) table and for every joined table, so the update reads the unfiltered rows. Repeatable: a later call accumulates with the earlier scope.

public UpdateJoinBuilder<TProjection> IgnoreFilters()

Returns

UpdateJoinBuilder<TProjection>

This builder, for chaining.

IgnoreFilters(IEnumerable<string>)

Disables the named global query filters identified by filterKeys on every entity type in the query. An empty or null filterKeys disables nothing. Repeatable: a later call accumulates (union) with the earlier scope.

public UpdateJoinBuilder<TProjection> IgnoreFilters(IEnumerable<string> filterKeys)

Parameters

filterKeys IEnumerable<string>

The filter keys to disable.

Returns

UpdateJoinBuilder<TProjection>

This builder, for chaining.

IgnoreFilters(IEnumerable<string>, params Type[])

Disables the named global query filters identified by filterKeys only on the given entityTypes (the intersection of keys and types); an empty entityTypes means any entity type. The key list is the gate: an empty or null filterKeys disables nothing even when entity types are supplied. Repeatable: a later call accumulates (union) with the earlier scope.

public UpdateJoinBuilder<TProjection> IgnoreFilters(IEnumerable<string> filterKeys, params Type[] entityTypes)

Parameters

filterKeys IEnumerable<string>

The filter keys to disable.

entityTypes Type[]

The entity types the disable is scoped to; empty means any entity type.

Returns

UpdateJoinBuilder<TProjection>

This builder, for chaining.

IgnoreFilters(params Type[])

Disables every global query filter declared for the given entity types (the target or any joined table). An empty or null entityTypes disables nothing. Repeatable: a later call accumulates (union) with the earlier scope.

public UpdateJoinBuilder<TProjection> IgnoreFilters(params Type[] entityTypes)

Parameters

entityTypes Type[]

The entity types whose filters are disabled.

Returns

UpdateJoinBuilder<TProjection>

This builder, for chaining.

Returning()

Switches the builder to the whole-projection (identity) row-returning terminal: every returnable mapped property of every item slot is returned, in slot order, so a self-join of one type keeps its Item1/Item2 values distinct (a repeated CLR type stays separated by slot). Equivalent to Returning(p => p). The updated rows carry the post-update target values, and the builder can be consumed directly or as a data-modifying CTE body through With(name, update). Returned columns get deterministic per-slot aliases; explicit projections are unchanged and no call adds a RETURNING list implicitly.

PostgreSQL only, on INNER joins and for arities 2–8; every other provider and every outer join rejects. A returned item whose mapped property is a multi-column Range<T> is rejected, as is a required member with no counterpart in the joined source shape.

public UpdateJoinReturningBuilder<TProjection, TProjection> Returning()

Returns

UpdateJoinReturningBuilder<TProjection, TProjection>

A returning builder whose terminals produce the full TProjection.

Exceptions

NotSupportedException

A returned mapped property is a multi-column Range<T>, or the provider/join is unsupported.

QueryPreparationException

A returned item slot has no registered entity metadata and exposes no readable columns.

Returning<TResult>(Expression<Func<TProjection, TResult>>)

Switches the builder to a row-returning terminal that materialises a projection of the updated rows through PostgreSQL's UPDATE ... FROM ... RETURNING form. A selected member may reference any joined table (for example Returning(p => new { p.Item1.Id, p.Item2.Name })). Only PostgreSQL supports returning rows from a multi-table update; every other provider rejects it.

public UpdateJoinReturningBuilder<TProjection, TResult> Returning<TResult>(Expression<Func<TProjection, TResult>> projection)

Parameters

projection Expression<Func<TProjection, TResult>>

Selects the mapped columns to return.

Returns

UpdateJoinReturningBuilder<TProjection, TResult>

A returning builder whose terminals produce TResult.

Type Parameters

TResult

The projected row shape.

Exceptions

NotSupportedException

The projection references something other than mapped properties.

Set<TValue>(Expression<Func<TProjection, TValue>>, Expression<Func<TProjection, TValue>>)

Assigns the result of an expression to a mapped column of the target (first) table. The expression is rendered by the same translator as a SELECT projection, so it may reference any joined table's columns (for example Set(p => p.Item1.Total, p => p.Item1.Total + p.Item2.Amount)) and captured variables (which become parameters).

public UpdateJoinBuilder<TProjection> Set<TValue>(Expression<Func<TProjection, TValue>> column, Expression<Func<TProjection, TValue>> value)

Parameters

column Expression<Func<TProjection, TValue>>

Selects the target-table column to write (for example p => p.Item1.Name).

value Expression<Func<TProjection, TValue>>

The value expression to evaluate.

Returns

UpdateJoinBuilder<TProjection>

This builder, for chaining.

Type Parameters

TValue

The column's CLR type.

Exceptions

ArgumentException

The selector does not target a column of the first table.

Set<TValue>(Expression<Func<TProjection, TValue>>, TValue)

Assigns a constant value to a mapped column of the target (first) table. The value is always bound as a parameter. Repeating the call for the same column replaces the earlier assignment.

public UpdateJoinBuilder<TProjection> Set<TValue>(Expression<Func<TProjection, TValue>> column, TValue value)

Parameters

column Expression<Func<TProjection, TValue>>

Selects the target-table column to write (for example p => p.Item1.Name).

value TValue

The value to write, or null for SQL NULL.

Returns

UpdateJoinBuilder<TProjection>

This builder, for chaining.

Type Parameters

TValue

The column's CLR type.

Exceptions

ArgumentException

The selector does not target a column of the first table.

ToSql()

Renders the parameterised SQL this builder would execute, without executing it. Useful for diagnostics and for verifying SQL generation without a database.

public string ToSql()

Returns

string

The rendered SQL text.

Exceptions

InvalidOperationException

No assignment was specified.

NotSupportedException

The context is not database-backed, the provider cannot express a multi-table UPDATE, or a join is not an INNER join.

Update()

Executes the update and returns the number of affected rows.

public int Update()

Returns

int

The number of updated rows, as reported by the provider.

Exceptions

InvalidOperationException

No assignment was specified.

NotSupportedException

The context is not database-backed, the provider cannot express a multi-table UPDATE, or a join is not an INNER join.

UpdateAsync(CancellationToken)

Asynchronously executes the update and returns the number of affected rows.

public Task<int> UpdateAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancels execution.

Returns

Task<int>

A task producing the number of updated rows.

Exceptions

InvalidOperationException

No assignment was specified.

NotSupportedException

The context is not database-backed, the provider cannot express a multi-table UPDATE, or a join is not an INNER join.

Where(Expression<Func<TProjection, bool>>)

Restricts the update to the rows satisfying predicate. The predicate is translated by the same expression pipeline as a SELECT WHERE and may reference any joined table. Repeating the call combines the predicates with and.

public UpdateJoinBuilder<TProjection> Where(Expression<Func<TProjection, bool>> predicate)

Parameters

predicate Expression<Func<TProjection, bool>>

The condition each updated row must satisfy.

Returns

UpdateJoinBuilder<TProjection>

This builder, for chaining.