public async Task CopyInput(bool useAllKeys = false) { await using (_WorkflowDbContext.BeginTransaction()) { await _ContentDbContext.EksInput.BatchDeleteAsync(); //TODO truncate instead await _ContentDbContext.EksOutput.BatchDeleteAsync(); var read = _WorkflowDbContext.TemporaryExposureKeys .Where(x => (x.Owner.Authorised || useAllKeys) && x.PublishingState == PublishingState.Unpublished) .Select(x => new EksCreateJobInputEntity { Id = x.Id, RollingPeriod = x.RollingPeriod, KeyData = x.KeyData, TransmissionRiskLevel = x.TransmissionRiskLevel, RollingStartNumber = x.RollingStartNumber, }).ToList(); await using (_ContentDbContext.BeginTransaction()) { await _ContentDbContext.BulkInsertAsync(read.ToList()); _ContentDbContext.SaveAndCommit(); } } }
public void Write(ExposureKeySetEntity[] things) { var entities = things.Select(x => new ExposureKeySetContentEntity { Content = x.Content, CreatingJobName = x.CreatingJobName, CreatingJobQualifier = x.CreatingJobQualifier, Release = x.Created, }).ToList(); foreach (var i in entities) { i.PublishingId = _PublishingId.Create(i.Content); } using (_DbContext.EnsureNoChangesOrTransaction().BeginTransaction()) { _DbContext.BulkInsertAsync(entities); _DbContext.SaveAndCommit(); } }