Example #1
0
 private static async Task RemoveEvents(
     EventStoreDbContext context,
     List <PendingEvent> pendingEvents,
     CancellationToken cancellationToken)
 {
     foreach (PendingEvent pendingEvent in pendingEvents)
     {
         try
         {
             context.PendingEvents.Remove(pendingEvent);
             await context.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
         }
         catch (DbUpdateConcurrencyException)
         {
             context.Entry(pendingEvent).State = EntityState.Detached;
         }
     }
 }
Example #2
0
        private static async Task RemoveEvents(
            EventStoreDbContext context,
            List <PendingEvent> pendingEvents,
            CancellationToken cancellationToken)
        {
            foreach (PendingEvent pendingEvent in pendingEvents)
            {
                try
                {
                    context.PendingEvents.Remove(pendingEvent);
                    await context.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
                }
#if NETSTANDARD2_0
                catch (DbUpdateConcurrencyException)
#else
                catch (DbUpdateConcurrencyException exception)
                    when(exception.InnerException is OptimisticConcurrencyException)
#endif
                {
                    context.Entry(pendingEvent).State = EntityState.Detached;
                }
            }
        }