Share via


RelationalQueryableExtensions.ExecuteDeleteAsync<TSource> Method

Definition

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

public static System.Threading.Tasks.Task<int> ExecuteDeleteAsync<TSource> (this System.Linq.IQueryable<TSource> source, System.Threading.CancellationToken cancellationToken = default);
static member ExecuteDeleteAsync : System.Linq.IQueryable<'Source> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<int>
<Extension()>
Public Function ExecuteDeleteAsync(Of TSource) (source As IQueryable(Of TSource), Optional cancellationToken As CancellationToken = Nothing) As Task(Of Integer)

Type Parameters

TSource

Parameters

source
IQueryable<TSource>

The source query.

cancellationToken
CancellationToken

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

Returns

The total number of rows deleted 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