internal override void FillDataTable(DataTable table, SqlBulkCopyDataWrapper input) { EnsureArg.IsNotNull(table, nameof(table)); EnsureArg.IsNotNull(input, nameof(input)); FillDataTable(table, input.ResourceTypeId, input.Resource.ResourceId, input.ResourceSurrogateId, input.CompressedRawData, input.Resource.SearchParameterHash); }
public async Task GivenListOfResourcesWithDupResourceId_WhenBulkMergeToStore_ThenDistinctResourceShouldBeImported() { List <SqlBulkCopyDataWrapper> resources = new List <SqlBulkCopyDataWrapper>(); long startSurrogateId = ResourceSurrogateIdHelper.LastUpdatedToResourceSurrogateId(DateTime.Now); SqlBulkCopyDataWrapper resource1 = CreateTestResource(Guid.NewGuid().ToString(), startSurrogateId); SqlBulkCopyDataWrapper resource2 = CreateTestResource(Guid.NewGuid().ToString(), startSurrogateId + 1); resources.Add(resource1); resources.Add(resource2); SqlBulkCopyDataWrapper[] result = (await _sqlServerFhirDataBulkOperation.BulkMergeResourceAsync(resources, CancellationToken.None)).ToArray(); int rCount = await GetResourceCountAsync("Resource", startSurrogateId, startSurrogateId + 2); Assert.Equal(2, result.Count()); Assert.Equal(2, rCount); resource1.ResourceSurrogateId = startSurrogateId + 2; resource1.ResourceSurrogateId = startSurrogateId + 3; result = (await _sqlServerFhirDataBulkOperation.BulkMergeResourceAsync(resources, CancellationToken.None)).ToArray(); rCount = await GetResourceCountAsync("Resource", startSurrogateId, startSurrogateId + 4); Assert.Empty(result); Assert.Equal(2, rCount); }
internal override void FillDataTable(DataTable table, SqlBulkCopyDataWrapper input) { EnsureArg.IsNotNull(table, nameof(table)); EnsureArg.IsNotNull(input, nameof(input)); foreach (var rowData in _generator.GenerateRows(new ResourceWrapper[] { input.Resource })) { FillDataTable(table, input.ResourceTypeId, input.ResourceSurrogateId, rowData); } }
internal override void FillDataTable(DataTable table, SqlBulkCopyDataWrapper input) { for (int i = 0; i < 2; ++i) { DataRow newRow = table.NewRow(); FillColumn(newRow, "ResourceSurrogateId", input.ResourceSurrogateId); table.Rows.Add(newRow); } }
internal override void FillDataTable(DataTable table, SqlBulkCopyDataWrapper input) { EnsureArg.IsNotNull(table, nameof(table)); EnsureArg.IsNotNull(input, nameof(input)); IEnumerable <BulkReferenceTokenCompositeSearchParamTableTypeV1Row> searchParams = _searchParamGenerator.GenerateRows(new ResourceWrapper[] { input.Resource }); foreach (BulkReferenceTokenCompositeSearchParamTableTypeV1Row searchParam in Distinct(searchParams)) { FillDataTable(table, input.ResourceTypeId, input.ResourceSurrogateId, searchParam); } }
internal override void FillDataTable(DataTable table, SqlBulkCopyDataWrapper input) { for (int i = 0; i < _subResourceCount; ++i) { DataRow newRow = table.NewRow(); FillColumn(newRow, "ResourceSurrogateId", input.ResourceSurrogateId); FillColumn(newRow, "Id", Guid.NewGuid().ToString("N")); table.Rows.Add(newRow); } }
internal override void FillDataTable(DataTable table, SqlBulkCopyDataWrapper input) { EnsureArg.IsNotNull(table, nameof(table)); EnsureArg.IsNotNull(input, nameof(input)); IEnumerable <BulkResourceWriteClaimTableTypeV1Row> claims = _generator.GenerateRows(new ResourceWrapper[] { input.Resource }); foreach (var claim in claims) { FillDataTable(table, input.ResourceSurrogateId, claim); } }
public async Task GivenListOfResources_WhenBulkMergeToStoreTwice_ThenSecondMergeShouldFail() { List <SqlBulkCopyDataWrapper> resources = new List <SqlBulkCopyDataWrapper>(); long startSurrogateId = ResourceSurrogateIdHelper.LastUpdatedToResourceSurrogateId(DateTime.Now); string resourceId = Guid.NewGuid().ToString(); SqlBulkCopyDataWrapper resource1 = CreateTestResource(resourceId, startSurrogateId); SqlBulkCopyDataWrapper resource2 = CreateTestResource(resourceId, startSurrogateId + 1); resources.Add(resource1); resources.Add(resource2); SqlBulkCopyDataWrapper[] result = (await _sqlServerFhirDataBulkOperation.BulkMergeResourceAsync(resources, CancellationToken.None)).ToArray(); int rCount = await GetResourceCountAsync("Resource", startSurrogateId, startSurrogateId + 2); Assert.Single(result); Assert.Equal(1, rCount); }
internal abstract void FillDataTable(DataTable table, SqlBulkCopyDataWrapper input);