Bulk operation (ARCH210)
Esta página aún no está disponible en tu idioma.
Key dotnet.ef.bulk-operation · Severity info · Category ef
Loading and modifying many rows one by one is far slower than ExecuteUpdate/ExecuteDelete, which run in a single SQL command.
Incorrect
Section titled “Incorrect”var expired = await _db.Tokens .Where(t => t.ExpiresAt < now) .ToListAsync();_db.Tokens.RemoveRange(expired);await _db.SaveChangesAsync();Correct
Section titled “Correct”await _db.Tokens .Where(t => t.ExpiresAt < now) .ExecuteDeleteAsync();Use ExecuteUpdateAsync or ExecuteDeleteAsync for bulk update/delete.