Skip to content

ExecuteUpdateExtensions.ExecuteUpsertGetRowsAsync.ZL88DR61E4TUW8Y3BY7UTAT62

Mike King edited this page Nov 9, 2025 · 1 revision

ExecuteUpdateExtensions.ExecuteUpsertGetRowsAsync<TSource>(this IQueryable<TSource>, Action<UpdateSettersBuilder<TSource>>, Action<UpdateSettersBuilder<TSource>>, CancellationToken) Method

Update the entity instances which match the LINQ query from the database or insert an entry if none exist.

public static System.Threading.Tasks.Task<System.Collections.Generic.IList<TSource>> ExecuteUpsertGetRowsAsync<TSource>(this System.Linq.IQueryable<TSource> source, System.Action<Microsoft.EntityFrameworkCore.Query.UpdateSettersBuilder<TSource>> updateSetPropertyCalls, System.Action<Microsoft.EntityFrameworkCore.Query.UpdateSettersBuilder<TSource>>? insertSetPropertyCalls=null, System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken))
    where TSource : class;

Type parameters

TSource

The type of the elements of source.

Parameters

source System.Linq.IQueryable<TSource>

An System.Linq.IQueryable<> whose elements to test for a condition.

updateSetPropertyCalls System.Action<Microsoft.EntityFrameworkCore.Query.UpdateSettersBuilder<TSource>>

A method containing set property statements specifying properties to update.

insertSetPropertyCalls System.Action<Microsoft.EntityFrameworkCore.Query.UpdateSettersBuilder<TSource>>

A method containing set property statements specifying properties to insert - if not specified the same properties as the update are used.

cancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns

System.Threading.Tasks.Task<System.Collections.Generic.IList<TSource>>
An System.Collections.Generic.IList<> containing the updated / inserted rows.

Clone this wiki locally