bulk-delete

C# Efficiently delete 50000 records in batches using SQLBulkCopy or equivalent library

本秂侑毒 提交于 2020-06-25 18:52:51
问题 I'm using this library to perform bulk delete in batches like following: while (castedEndedItems.Any()) { var subList = castedEndedItems.Take(4000).ToList(); DBRetry.Do(() => EFBatchOperation.For(ctx, ctx.SearchedUserItems).Where(r => subList.Any(a => a == r.ItemID)).Delete(), TimeSpan.FromSeconds(2)); castedEndedItems.RemoveRange(0, subList.Count); Console.WriteLine("Completed a batch of ended items"); } As you can see guys I take a batch of 4000 items to delete at once and I pass them as