Bulk delete and context changes

Thread is closed for posting
1 posts, 0 answers
  1. Bernd
    Bernd avatar
    91 posts
    Member since:
    Feb 2013

    Posted 05 Jan 2017 Link to this post

    Hi there.

    I a larger operataion I am using the bulk delete and later on the GetChanges to tell clients what happend. It seems the bulk deletes are not logged. Is that a flaw or by design? How can I get the deleted rows?

    The code snippet:

    01. IQueryable<CalendarEvent> eventsToDelete = _db.CalendarEvents.Where(...);
    02.eventsToDelete.DeleteAll();
    03.// do some other stuff
    04. 
    05.// GetChanges
    06.ContextChanges contextChanges = _db.GetChanges();
    07.result.Created = contextChanges.GetInserts<CalendarEvent>();
    08.result.Updated = contextChanges.GetUpdates<CalendarEvent>();
    09.result.Deleted = contextChanges.GetDeletes<CalendarEvent>();
    10. 
    11.// the ids of the created rows are filled during SaveChanges
    12._db.SaveChanges();
Back to Top