Delen via


DbSet<TEntity>.RemoveRange Method

Definition

Overloads

RemoveRange(IEnumerable<TEntity>)

Begins tracking the given entities in the Deleted state such that they will be removed from the database when SaveChanges() is called.

RemoveRange(TEntity[])

Begins tracking the given entities in the Deleted state such that they will be removed from the database when SaveChanges() is called.

RemoveRange(IEnumerable<TEntity>)

Source:
DbSet%60.cs
Source:
DbSet%60.cs
Source:
DbSet.cs
Source:
DbSet.cs
Source:
DbSet.cs
Source:
DbSet.cs
Source:
DbSet.cs
Source:
DbSet.cs
Source:
DbSet.cs

Begins tracking the given entities in the Deleted state such that they will be removed from the database when SaveChanges() is called.

public virtual void RemoveRange (System.Collections.Generic.IEnumerable<TEntity> entities);
abstract member RemoveRange : seq<'Entity (requires 'Entity : null)> -> unit
override this.RemoveRange : seq<'Entity (requires 'Entity : null)> -> unit
Public Overridable Sub RemoveRange (entities As IEnumerable(Of TEntity))

Parameters

entities
IEnumerable<TEntity>

The entities to remove.

Remarks

If any of the entities are already tracked in the Added state then the context will stop tracking those entities (rather than marking them as Deleted) since those entities were previously added to the context and do not exist in the database.

Any other reachable entities that are not already being tracked will be tracked in the same way that they would be if AttachRange(IEnumerable<TEntity>) was called before calling this method. This allows any cascading actions to be applied when SaveChanges() is called.

See EF Core change tracking and Using AddRange, UpdateRange, AttachRange, and RemoveRange for more information and examples.

Applies to

RemoveRange(TEntity[])

Source:
DbSet%60.cs
Source:
DbSet%60.cs
Source:
DbSet.cs
Source:
DbSet.cs
Source:
DbSet.cs
Source:
DbSet.cs
Source:
DbSet.cs
Source:
DbSet.cs
Source:
DbSet.cs

Begins tracking the given entities in the Deleted state such that they will be removed from the database when SaveChanges() is called.

public virtual void RemoveRange (params TEntity[] entities);
abstract member RemoveRange : 'Entity[] -> unit
override this.RemoveRange : 'Entity[] -> unit
Public Overridable Sub RemoveRange (ParamArray entities As TEntity())

Parameters

entities
TEntity[]

The entities to remove.

Remarks

If any of the entities are already tracked in the Added state then the context will stop tracking those entities (rather than marking them as Deleted) since those entities were previously added to the context and do not exist in the database.

Any other reachable entities that are not already being tracked will be tracked in the same way that they would be if AttachRange(TEntity[]) was called before calling this method. This allows any cascading actions to be applied when SaveChanges() is called.

See EF Core change tracking and Using AddRange, UpdateRange, AttachRange, and RemoveRange for more information and examples.

Applies to