public async Task Handle(GendersChanged @event) { var deleted = @event.Deleted; await _context.Genders .Where(x => deleted.Contains(x.Id)) .DeleteFromQueryAsync(); var toMergeDto = @event.Created.Concat(@event.Updated); var toMerge = toMergeDto .Select(Mapper.Map <Gender>) .ToList(); await _context.BulkMergeAsync( toMerge, opt => opt.MergeKeepIdentity = true); }
public async Task Handle(AreasChanged @event) { var deleted = @event.Deleted; await _context.Areas .Where(x => deleted.Contains(x.Id)) .DeleteFromQueryAsync(); var toMergeDto = @event.Created.Concat(@event.Updated); var toMerge = toMergeDto .Select(Mapper.Map <Area>) .ToList(); await _context.BulkMergeAsync( toMerge, opt => { opt.MergeKeepIdentity = true; opt.IncludeGraph = true; }); }