DbSet<TEntity>.RemoveRange(IEnumerable<TEntity>) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Removes the given collection of entities from the context underlying the set with each entity being put into the Deleted state such that it will be deleted from the database when SaveChanges is called.
public virtual System.Collections.Generic.IEnumerable<TEntity> RemoveRange (System.Collections.Generic.IEnumerable<TEntity> entities);
abstract member RemoveRange : seq<'Entity (requires 'Entity : null)> -> seq<'Entity (requires 'Entity : null)>
override this.RemoveRange : seq<'Entity (requires 'Entity : null)> -> seq<'Entity (requires 'Entity : null)>
Public Overridable Function RemoveRange (entities As IEnumerable(Of TEntity)) As IEnumerable(Of TEntity)
Parameters
- entities
- IEnumerable<TEntity>
The collection of entities to delete.
Returns
The collection of entities.
Remarks
Note that if AutoDetectChangesEnabled is set to true (which is the default), then DetectChanges will be called once before delete any entities and will not be called again. This means that in some situations RemoveRange may perform significantly better than calling Remove multiple times would do. Note that if any entity exists in the context in the Added state, then this method will cause it to be detached from the context. This is because an Added entity is assumed not to exist in the database such that trying to delete it does not make sense.
Applies to
Entity Framework