İçeriğe geç

Bulk operation (ARCH210)

Anahtar dotnet.ef.bulk-operation · Onem info · Kategori ef

Cok sayida satiri tek tek yukleyip degistirmek yerine ExecuteUpdate/ExecuteDelete tek bir SQL komutuyla calisir.

var expired = await _db.Tokens
.Where(t => t.ExpiresAt < now)
.ToListAsync();
_db.Tokens.RemoveRange(expired);
await _db.SaveChangesAsync();
await _db.Tokens
.Where(t => t.ExpiresAt < now)
.ExecuteDeleteAsync();

Toplu guncelleme/silme icin ExecuteUpdateAsync veya ExecuteDeleteAsync kullanin.