RelationalQueryableExtensions.ExecuteUpdateAsync<TSource> Method

Definition

Asynchronously updates database rows for the entity instances which match the LINQ query from the database.

public static System.Threading.Tasks.Task<int> ExecuteUpdateAsync<TSource> (this System.Linq.IQueryable<TSource> source, System.Linq.Expressions.Expression<Func<Microsoft.EntityFrameworkCore.Query.SetPropertyCalls<TSource>,Microsoft.EntityFrameworkCore.Query.SetPropertyCalls<TSource>>> setPropertyCalls, System.Threading.CancellationToken cancellationToken = default);
static member ExecuteUpdateAsync : System.Linq.IQueryable<'Source> * System.Linq.Expressions.Expression<Func<Microsoft.EntityFrameworkCore.Query.SetPropertyCalls<'Source>, Microsoft.EntityFrameworkCore.Query.SetPropertyCalls<'Source>>> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<int>
<Extension()>
Public Function ExecuteUpdateAsync(Of TSource) (source As IQueryable(Of TSource), setPropertyCalls As Expression(Of Func(Of SetPropertyCalls(Of TSource), SetPropertyCalls(Of TSource))), Optional cancellationToken As CancellationToken = Nothing) As Task(Of Integer)

Type Parameters

TSource

Parameters

source
IQueryable<TSource>

The source query.

setPropertyCalls
Expression<Func<SetPropertyCalls<TSource>,SetPropertyCalls<TSource>>>

A collection of set property statements specifying properties to update.

cancellationToken
CancellationToken

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

Returns

The total number of rows updated in the database.

Remarks

This operation executes immediately against the database, rather than being deferred until SaveChanges() is called. It also does not interact with the EF change tracker in any way: entity instances which happen to be tracked when this operation is invoked aren't taken into account, and aren't updated to reflect the changes.

See Executing bulk operations with EF Core for more information and examples.

Applies to