public async Task Delete(ICollection <T> entities) { foreach (var obj in entities) { EntityEntry dbEntity = Context.Entry(obj); if (dbEntity.State != EntityState.Deleted) { dbEntity.State = EntityState.Deleted; } else { DBSet.Attach(obj); } } await Task.Run(() => { DBSet.RemoveRange(entities); }); }
public IList <TEntity> DeleteAll(IEnumerable <TEntity> entities) { return(DBSet.RemoveRange(entities).ToList()); }