public async Task SaveChangesAsync() { if (unsavedChangeRecords.Count == 0) { return; } var recs = unsavedChangeRecords.ToList(); unsavedChangeRecords.Clear(); crudRepository.AddRange(recs); await crudRepository.SaveChangesAsync(); foreach (TrackedChangeRecord changeRecord in recs) { await eventBus.PublishAsync(new EventMessage <TrackedChangeAdded>( new TrackedChangeAdded() { TrackedChangeId = changeRecord.Id, AggregateClassId = changeRecord.AggregateClassId, AggregateId = changeRecord.AggregateId, EntityClassId = changeRecord.EntityClassId, EntityId = changeRecord.EntityId }, new Dictionary <string, string>())); } }
public async Task <IEnumerable <TKey> > Add(IEnumerable <T> values) { using (var trans = _unitOfWork.BeginTransaction()) { await ValidateDto(values, ValidationType.AddValidation); var entities = MapFromDtos(values, ValidationType.AddValidation); foreach (var entity in entities) { AddEntity(entity); } _repository.AddRange(entities); await CommitTransaction(trans); return(entities.Select(GetKey)); } }