Interface IUpsertSpec<TTarget>
Fluent configuration builder for an Upsert (insert-or-update) operation.
Returned to the caller of an Upsert extension method through a configuration lambda.
public interface IUpsertSpec<TTarget> where TTarget : notnull
Type Parameters
TTargetTarget table record type.
- Extension Methods
Remarks
This interface is used only as the receiver type of an expression tree captured by linq2db. The configure expression is parsed by linq2db and is not invoked; implementing this interface is not a supported extension point.
Methods
Ignore<TV>(Expression<Func<TTarget, TV>>)
Excludes a target column from both INSERT and UPDATE.
IUpsertSpec<TTarget> Ignore<TV>(Expression<Func<TTarget, TV>> field)
Parameters
fieldExpression<Func<TTarget, TV>>
Returns
- IUpsertSpec<TTarget>
Type Parameters
TV
Insert(Expression<Func<IUpsertInsertSpec<TTarget>, IUpsertInsertSpec<TTarget>>>)
Configures the INSERT branch.
IUpsertSpec<TTarget> Insert(Expression<Func<IUpsertInsertSpec<TTarget>, IUpsertInsertSpec<TTarget>>> configure)
Parameters
configureExpression<Func<IUpsertInsertSpec<TTarget>, IUpsertInsertSpec<TTarget>>>
Returns
- IUpsertSpec<TTarget>
Match(Expression<Func<TTarget, TTarget, bool>>)
Defines the key-equality used to match source rows to target rows: a conjunction of equality
comparisons between target and source member paths — e.g. (t, s) => t.Id == s.Id or
(t, s) => t.TenantId == s.TenantId && t.ExternalId == s.ExternalId. This is not a
general boolean predicate; use the branch .When(...) predicates for conditional
INSERT/UPDATE logic. When omitted, the target table's primary key is used (same as today's
InsertOrUpdate). Columns referenced by the match identify the row and are excluded
from the UPDATE branch's SET list.
IUpsertSpec<TTarget> Match(Expression<Func<TTarget, TTarget, bool>> matchCondition)
Parameters
matchConditionExpression<Func<TTarget, TTarget, bool>>
Returns
- IUpsertSpec<TTarget>
Set<TV>(Expression<Func<TTarget, TV>>, Expression<Func<TTarget, TV>>)
Sets a target column's value for both INSERT and UPDATE branches from the source row.
IUpsertSpec<TTarget> Set<TV>(Expression<Func<TTarget, TV>> field, Expression<Func<TTarget, TV>> value)
Parameters
fieldExpression<Func<TTarget, TV>>valueExpression<Func<TTarget, TV>>
Returns
- IUpsertSpec<TTarget>
Type Parameters
TV
Set<TV>(Expression<Func<TTarget, TV>>, Expression<Func<TV>>)
Sets a target column's value for both INSERT and UPDATE branches from a context-free expression.
IUpsertSpec<TTarget> Set<TV>(Expression<Func<TTarget, TV>> field, Expression<Func<TV>> value)
Parameters
fieldExpression<Func<TTarget, TV>>valueExpression<Func<TV>>
Returns
- IUpsertSpec<TTarget>
Type Parameters
TV
SkipInsert()
Skips the INSERT branch entirely — UPDATE-IF-EXISTS semantics.
IUpsertSpec<TTarget> SkipInsert()
Returns
- IUpsertSpec<TTarget>
SkipUpdate()
Skips the UPDATE branch entirely — INSERT-IF-NOT-EXISTS semantics.
IUpsertSpec<TTarget> SkipUpdate()
Returns
- IUpsertSpec<TTarget>
Update(Expression<Func<IUpsertUpdateSpec<TTarget>, IUpsertUpdateSpec<TTarget>>>)
Configures the UPDATE branch.
IUpsertSpec<TTarget> Update(Expression<Func<IUpsertUpdateSpec<TTarget>, IUpsertUpdateSpec<TTarget>>> configure)
Parameters
configureExpression<Func<IUpsertUpdateSpec<TTarget>, IUpsertUpdateSpec<TTarget>>>
Returns
- IUpsertSpec<TTarget>