SQLProvider

SqlEntityConflictExtensions Type

Typed conflict handling for an inserted row (OnConflict.DoNothingOn and UpdateOn, with the columns checked by the compiler).

Static members

Static member Description

SqlEntityConflictExtensions.OnConflictDoNothing(row, conflictColumns)

Full Usage: SqlEntityConflictExtensions.OnConflictDoNothing(row, conflictColumns)

Parameters:
    row : 'T - The row to insert.
    conflictColumns : Expr<('T -> 'Key)> - The constraint's or index's columns: a property of the row, or a tuple of them, e.g. fun r -> r.Code or fun r -> (r.Code, r.Region).

Type parameters: 'T, 'Key (requires :> FSharp.Data.Sql.Common.SqlEntity)

When the inserted row breaks the unique constraint or index on exactly the given columns, the existing row stays as it is: ON CONFLICT (columns) DO NOTHING.

Sets row.OnConflict to OnConflict.DoNothingOn. PostgreSQL, SQLite 3.24+ and DuckDB; MySQL and the databases without an upsert refuse it when the row is submitted.

row : 'T

The row to insert.

conflictColumns : Expr<('T -> 'Key)>

The constraint's or index's columns: a property of the row, or a tuple of them, e.g. fun r -> r.Code or fun r -> (r.Code, r.Region).

SqlEntityConflictExtensions.OnConflictUpdate(row, conflictColumns, update)

Full Usage: SqlEntityConflictExtensions.OnConflictUpdate(row, conflictColumns, update)

Parameters:
    row : 'T - The row to insert.
    conflictColumns : Expr<('T -> 'Key)> - The constraint's or index's columns: a property of the row, or a tuple of them, e.g. fun r -> r.Code or fun r -> (r.Code, r.Region).
    update : Expr<('T -> 'T -> unit)> - Sets properties of the existing row, each to the inserted row's value of the same property or to a value known before the insert (a constant or a captured value), e.g. fun existing inserted -> existing.Name <- inserted.Name; existing.Note <- "merged". Properties not set keep their old values.

Type parameters: 'T, 'Key (requires :> FSharp.Data.Sql.Common.SqlEntity)

When the inserted row breaks the unique constraint or index on exactly the given columns, the existing row changes as the update says: ON CONFLICT (columns) DO UPDATE SET ....

Sets row.OnConflict to OnConflict.UpdateOn. A value computed from the rows, such as existing.Count + 1, is refused, and so is an update that sets nothing or one property twice. PostgreSQL, SQLite 3.24+ and DuckDB; MySQL and the databases without an upsert refuse it when the row is submitted.

row : 'T

The row to insert.

conflictColumns : Expr<('T -> 'Key)>

The constraint's or index's columns: a property of the row, or a tuple of them, e.g. fun r -> r.Code or fun r -> (r.Code, r.Region).

update : Expr<('T -> 'T -> unit)>

Sets properties of the existing row, each to the inserted row's value of the same property or to a value known before the insert (a constant or a captured value), e.g. fun existing inserted -> existing.Name <- inserted.Name; existing.Note <- "merged". Properties not set keep their old values.

Type something to start searching.