public async Task <WorkflowDefinitionVersionEntity> Add(WorkflowDefinitionVersionEntity entity) { entity.Id = Guid.NewGuid(); foreach (var item in entity.Activities) { item.WorkflowDefinitionVersion = entity.Id; } foreach (var item in entity.Connections) { item.WorkflowDefinitionVersion = entity.Id; } using var uow = _elsaDbContext.NewUnitOfWork(); if (!await _repository.AddAsync(entity, uow)) { throw new Exception("Ìí¼Óʧ°Ü"); } if (!await _activityDefinitionRepository.BatchInsertAsync(entity.Activities.ToList(), uow)) { throw new Exception("Ìí¼Óʧ°Ü"); } if (!await _connectionDefinitionRepository.BatchInsertAsync(entity.Connections.ToList(), uow)) { throw new Exception("Ìí¼Óʧ°Ü"); } uow.Commit(); return(entity); }