Skip to content

Commit

Permalink
Merge pull request #50 from Avanade/v2.6.0
Browse files Browse the repository at this point in the history
v2.6.0
  • Loading branch information
chullybun authored Oct 2, 2024
2 parents 5c72b0d + b37d700 commit 3b8859d
Show file tree
Hide file tree
Showing 53 changed files with 128 additions and 254 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

Represents the **NuGet** versions.

## v2.6.0
- *Enhancement:* Database code-generation defaults to the use of [JSON](https://learn.microsoft.com/en-us/sql/relational-databases/json/json-data-sql-server)-serialized parameters versus UDT/TVP to minimize the need for additional database objects; specifically [User-Defined Types](https://learn.microsoft.com/en-us/sql/t-sql/statements/create-type-transact-sql) (UDT).
- This will now require a SQL Server version of 2016 or later; use earlier _DbEx_ versions that use UDT/TVP which are supported on earlier SQL Server versions.
- *Enhancement:* All code-generated stored procedures now use `CREATE OR ALTER`; again, requires SQL Server 2016 or later.

## v2.5.2
- *Fixed:* Updated `CoreEx` (`v3.15.0`) and other dependencies.
- *Fixed:* Simplify event outbox C# code-generation templates for primary constructor usage.
Expand Down
2 changes: 1 addition & 1 deletion Common.targets
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>2.5.2</Version>
<Version>2.6.0</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>NTangle Developers</Authors>
<Company>Avanade</Company>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="DbEx.SqlServer" Version="2.5.1" />
<PackageReference Include="DbEx.SqlServer" Version="2.6.1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup> <ItemGroup>
<PackageReference Include="CoreEx.Azure" Version="3.15.0" />
<PackageReference Include="CoreEx.Database.SqlServer" Version="3.15.0" />
<PackageReference Include="CoreEx.Validation" Version="3.15.0" />
<PackageReference Include="CoreEx.Azure" Version="3.25.6" />
<PackageReference Include="CoreEx.Database.SqlServer" Version="3.25.6" />
<PackageReference Include="CoreEx.Validation" Version="3.25.6" />
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="5.14.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="5.16.4" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.3.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="DbEx.SqlServer" Version="2.5.1" />
<PackageReference Include="DbEx.SqlServer" Version="2.6.1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CREATE PROCEDURE [NTangle].[spContactBatchComplete]
CREATE OR ALTER PROCEDURE [NTangle].[spContactBatchComplete]
@BatchTrackingId BIGINT,
@VersionTrackingList AS [NTangle].[udtVersionTrackingList] READONLY
@VersionTrackingList AS NVARCHAR(MAX)
AS
BEGIN
/*
Expand Down Expand Up @@ -35,14 +35,16 @@ BEGIN
DECLARE @Timestamp DATETIME2
SET @Timestamp = GETUTCDATE()

SELECT * into #versionTrackingList FROM OPENJSON(@VersionTrackingList) WITH ([Key] NVARCHAR(255) '$.key', [Hash] NVARCHAR(127) '$.hash')

UPDATE [_batch] SET
[_batch].[IsComplete] = 1,
[_batch].[CompletedDate] = @Timestamp
FROM [NTangle].[ContactBatchTracking] AS [_batch]
WHERE BatchTrackingId = @BatchTrackingId

MERGE INTO [NTangle].[VersionTracking] WITH (HOLDLOCK) AS [_vt]
USING @VersionTrackingList AS [_list] ON ([_vt].[Schema] = N'old' AND [_vt].[Table] = N'Contact' AND [_vt].[Key] = [_list].[Key])
USING #versionTrackingList AS [_list] ON ([_vt].[Schema] = N'old' AND [_vt].[Table] = N'Contact' AND [_vt].[Key] = [_list].[Key])
WHEN MATCHED AND EXISTS (
SELECT [_list].[Key], [_list].[Hash]
EXCEPT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CREATE PROCEDURE [NTangle].[spContactBatchExecute]
CREATE OR ALTER PROCEDURE [NTangle].[spContactBatchExecute]
@MaxQuerySize BIGINT = 100, -- Maximum size of query to limit the number of changes to a manageable batch (performance vs failure trade-off).
@ContinueWithDataLoss BIT = 0 -- Ignores data loss and continues; versus throwing an error.
AS
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CREATE PROCEDURE [NTangle].[spContactBatchReset]
CREATE OR ALTER PROCEDURE [NTangle].[spContactBatchReset]
AS
BEGIN
/*
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CREATE PROCEDURE [Outbox].[spEventOutboxDequeue]
CREATE OR ALTER PROCEDURE [Outbox].[spEventOutboxDequeue]
@MaxDequeueSize INT = 10, -- Maximum number of events to dequeue.
@PartitionKey NVARCHAR(127) NULL = NULL, -- Partition key; null indicates all.
@Destination NVARCHAR(127) NULL = NULL -- Destination (queue or topic); null indicates all.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CREATE PROCEDURE [Outbox].[spEventOutboxEnqueue]
CREATE OR ALTER PROCEDURE [Outbox].[spEventOutboxEnqueue]
@SetEventsAsDequeued AS BIT = 0,
@EventList AS [Outbox].[udtEventOutboxList] READONLY
@EventList AS NVARCHAR(MAX)
AS
BEGIN
/*
Expand All @@ -24,6 +24,24 @@ BEGIN
-- Enqueued outbox resultant identifier.
DECLARE @enqueuedId TABLE([EventOutboxId] BIGINT)

-- Convert the JSON to a temporary table.
SELECT * INTO #eventList FROM OPENJSON(@EventList) WITH (
[EventId] NVARCHAR(127) '$.EventId',
[EventDequeued] BIT '$.EventDequeued',
[Destination] NVARCHAR(127) '$.Destination',
[Subject] NVARCHAR(511) '$.Subject',
[Action] NVARCHAR(255) '$.Action',
[Type] NVARCHAR(1023) '$.Type',
[Source] NVARCHAR(1023) '$.Source',
[Timestamp] DATETIMEOFFSET '$.Timestamp',
[CorrelationId] NVARCHAR(127) '$.CorrelationId',
[Key] NVARCHAR(1023) '$.Key',
[TenantId] NVARCHAR(127) '$.TenantId',
[PartitionKey] NVARCHAR(127) '$.PartitionKey',
[ETag] NVARCHAR(127) '$.ETag',
[Attributes] VARBINARY(MAX) '$.Attributes',
[Data] VARBINARY(MAX) '$.Data')

-- Cursor output variables.
DECLARE @eventId NVARCHAR(127),
@eventDequeued BIT,
Expand All @@ -43,7 +61,7 @@ BEGIN

-- Declare, open, and fetch first event from cursor.
DECLARE c CURSOR FORWARD_ONLY
FOR SELECT [EventId], [EventDequeued], [Destination], [Subject], [Action], [Type], [Source], [Timestamp], [CorrelationId], [Key], [TenantId], [PartitionKey], [ETag], [Attributes], [Data] FROM @EventList
FOR SELECT [EventId], [EventDequeued], [Destination], [Subject], [Action], [Type], [Source], [Timestamp], [CorrelationId], [Key], [TenantId], [PartitionKey], [ETag], [Attributes], [Data] FROM #eventList

OPEN c
FETCH NEXT FROM c INTO @eventId, @eventDequeued, @destination, @subject, @action, @type, @source, @timestamp, @correlationId, @key, @tenantId, @partitionKey, @etag, @attributes, @data
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
<Folder Include="Entities\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="CoreEx.Azure" Version="3.15.0" />
<PackageReference Include="CoreEx.Azure" Version="3.25.6" />
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="5.14.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="5.16.4" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.3.0" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ namespace ContactSync.OldApp.Publisher.Data;
/// <param name="logger">The <see cref="ILogger"/>.</param>
public sealed class EventOutboxEnqueue(IDatabase database, ILogger<EventOutboxEnqueue> logger) : EventOutboxEnqueueBase(database, logger)
{
/// <inheritdoc/>
protected override string DbTvpTypeName => "[Outbox].[udtEventOutboxList]";

/// <inheritdoc/>
protected override string EnqueueStoredProcedure => "[Outbox].[spEventOutboxEnqueue]";
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CREATE PROCEDURE [NTangle].[spContactBatchComplete]
CREATE OR ALTER PROCEDURE [NTangle].[spContactBatchComplete]
@BatchTrackingId BIGINT,
@VersionTrackingList AS [NTangle].[udtVersionTrackingList] READONLY
@VersionTrackingList AS NVARCHAR(MAX)
AS
BEGIN
/*
Expand Down Expand Up @@ -35,14 +35,16 @@ BEGIN
DECLARE @Timestamp DATETIME2
SET @Timestamp = GETUTCDATE()

SELECT * into #versionTrackingList FROM OPENJSON(@VersionTrackingList) WITH ([Key] NVARCHAR(255) '$.key', [Hash] NVARCHAR(127) '$.hash')

UPDATE [_batch] SET
[_batch].[IsComplete] = 1,
[_batch].[CompletedDate] = @Timestamp
FROM [NTangle].[ContactBatchTracking] AS [_batch]
WHERE BatchTrackingId = @BatchTrackingId

MERGE INTO [NTangle].[VersionTracking] WITH (HOLDLOCK) AS [_vt]
USING @VersionTrackingList AS [_list] ON ([_vt].[Schema] = N'Legacy' AND [_vt].[Table] = N'Contact' AND [_vt].[Key] = [_list].[Key])
USING #versionTrackingList AS [_list] ON ([_vt].[Schema] = N'Legacy' AND [_vt].[Table] = N'Contact' AND [_vt].[Key] = [_list].[Key])
WHEN MATCHED AND EXISTS (
SELECT [_list].[Key], [_list].[Hash]
EXCEPT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CREATE PROCEDURE [NTangle].[spContactBatchExecute]
CREATE OR ALTER PROCEDURE [NTangle].[spContactBatchExecute]
@MaxQuerySize BIGINT = 100, -- Maximum size of query to limit the number of changes to a manageable batch (performance vs failure trade-off).
@ContinueWithDataLoss BIT = 0 -- Ignores data loss and continues; versus throwing an error.
AS
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CREATE PROCEDURE [NTangle].[spContactBatchReset]
CREATE OR ALTER PROCEDURE [NTangle].[spContactBatchReset]
AS
BEGIN
/*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CREATE PROCEDURE [NTangle].[spCustomerBatchComplete]
CREATE OR ALTER PROCEDURE [NTangle].[spCustomerBatchComplete]
@BatchTrackingId BIGINT,
@VersionTrackingList AS [NTangle].[udtVersionTrackingList] READONLY
@VersionTrackingList AS NVARCHAR(MAX)
AS
BEGIN
/*
Expand Down Expand Up @@ -35,14 +35,16 @@ BEGIN
DECLARE @Timestamp DATETIME2
SET @Timestamp = GETUTCDATE()

SELECT * into #versionTrackingList FROM OPENJSON(@VersionTrackingList) WITH ([Key] NVARCHAR(255) '$.key', [Hash] NVARCHAR(127) '$.hash')

UPDATE [_batch] SET
[_batch].[IsComplete] = 1,
[_batch].[CompletedDate] = @Timestamp
FROM [NTangle].[CustomerBatchTracking] AS [_batch]
WHERE BatchTrackingId = @BatchTrackingId

MERGE INTO [NTangle].[VersionTracking] WITH (HOLDLOCK) AS [_vt]
USING @VersionTrackingList AS [_list] ON ([_vt].[Schema] = N'Legacy' AND [_vt].[Table] = N'Customer' AND [_vt].[Key] = [_list].[Key])
USING #versionTrackingList AS [_list] ON ([_vt].[Schema] = N'Legacy' AND [_vt].[Table] = N'Customer' AND [_vt].[Key] = [_list].[Key])
WHEN MATCHED AND EXISTS (
SELECT [_list].[Key], [_list].[Hash]
EXCEPT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CREATE PROCEDURE [NTangle].[spCustomerBatchExecute]
CREATE OR ALTER PROCEDURE [NTangle].[spCustomerBatchExecute]
@MaxQuerySize BIGINT = 100, -- Maximum size of query to limit the number of changes to a manageable batch (performance vs failure trade-off).
@ContinueWithDataLoss BIT = 0 -- Ignores data loss and continues; versus throwing an error.
AS
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CREATE PROCEDURE [NTangle].[spCustomerBatchReset]
CREATE OR ALTER PROCEDURE [NTangle].[spCustomerBatchReset]
AS
BEGIN
/*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CREATE PROCEDURE [NTangle].[spIdentifierMappingCreate]
@IdentifierList AS [NTangle].[udtIdentifierMappingList] READONLY
CREATE OR ALTER PROCEDURE [NTangle].[spIdentifierMappingCreate]
@IdentifierList AS NVARCHAR(MAX)
AS
BEGIN
/*
Expand All @@ -12,18 +12,21 @@ BEGIN
-- Wrap in a transaction.
BEGIN TRANSACTION

-- Create a temporary table to hold the list of identifiers.
SELECT * INTO #identifierList FROM OPENJSON(@IdentifierList) WITH ([Schema] NVARCHAR(50) '$.schema', [Table] NVARCHAR(127) '$.table', [Key] NVARCHAR(255) '$.key', [GlobalId] NVARCHAR(127) '$.globalId')

-- Insert the Identifier only where a value does not already currently exist.
INSERT INTO [NTangle].[IdentifierMapping]
([Schema], [Table], [Key], [GlobalId])
SELECT [n].[Schema], [n].[Table], [n].[Key], [n].[GlobalId]
FROM @IdentifierList AS [n]
FROM #identifierList AS [n]
WHERE NOT EXISTS (SELECT 0 FROM [NTangle].[IdentifierMapping] AS [o]
WHERE [n].[Schema] = [o].[Schema] AND [n].[Table] = [o].[Table] AND [n].[Key] = [o].[Key])

-- Get the latest (current) values as some may already have had a global idenfifier created (i.e. not inserted above).
SELECT [n].[Schema], [n].[Table], [n].[Key], [n].[GlobalId]
FROM [NTangle].[IdentifierMapping] AS [n]
INNER JOIN @IdentifierList AS [o] ON [n].[Schema] = [o].[Schema] AND [n].[Table] = [o].[Table] AND [n].[Key] = [o].[Key]
INNER JOIN #identifierList AS [o] ON [n].[Schema] = [o].[Schema] AND [n].[Table] = [o].[Table] AND [n].[Key] = [o].[Key]

-- Commit the transaction.
COMMIT TRANSACTION
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CREATE PROCEDURE [NTangle].[spPostsBatchComplete]
CREATE OR ALTER PROCEDURE [NTangle].[spPostsBatchComplete]
@BatchTrackingId BIGINT,
@VersionTrackingList AS [NTangle].[udtVersionTrackingList] READONLY
@VersionTrackingList AS NVARCHAR(MAX)
AS
BEGIN
/*
Expand Down Expand Up @@ -35,14 +35,16 @@ BEGIN
DECLARE @Timestamp DATETIME2
SET @Timestamp = GETUTCDATE()

SELECT * into #versionTrackingList FROM OPENJSON(@VersionTrackingList) WITH ([Key] NVARCHAR(255) '$.key', [Hash] NVARCHAR(127) '$.hash')

UPDATE [_batch] SET
[_batch].[IsComplete] = 1,
[_batch].[CompletedDate] = @Timestamp
FROM [NTangle].[PostsBatchTracking] AS [_batch]
WHERE BatchTrackingId = @BatchTrackingId

MERGE INTO [NTangle].[VersionTracking] WITH (HOLDLOCK) AS [_vt]
USING @VersionTrackingList AS [_list] ON ([_vt].[Schema] = N'Legacy' AND [_vt].[Table] = N'Posts' AND [_vt].[Key] = [_list].[Key])
USING #versionTrackingList AS [_list] ON ([_vt].[Schema] = N'Legacy' AND [_vt].[Table] = N'Posts' AND [_vt].[Key] = [_list].[Key])
WHEN MATCHED AND EXISTS (
SELECT [_list].[Key], [_list].[Hash]
EXCEPT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CREATE PROCEDURE [NTangle].[spPostsBatchExecute]
CREATE OR ALTER PROCEDURE [NTangle].[spPostsBatchExecute]
@MaxQuerySize BIGINT = 100, -- Maximum size of query to limit the number of changes to a manageable batch (performance vs failure trade-off).
@ContinueWithDataLoss BIT = 0 -- Ignores data loss and continues; versus throwing an error.
AS
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CREATE PROCEDURE [NTangle].[spPostsBatchReset]
CREATE OR ALTER PROCEDURE [NTangle].[spPostsBatchReset]
AS
BEGIN
/*
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CREATE PROCEDURE [Outbox].[spEventOutboxDequeue]
CREATE OR ALTER PROCEDURE [Outbox].[spEventOutboxDequeue]
@MaxDequeueSize INT = 10, -- Maximum number of events to dequeue.
@PartitionKey NVARCHAR(127) NULL = NULL, -- Partition key; null indicates all.
@Destination NVARCHAR(127) NULL = NULL -- Destination (queue or topic); null indicates all.
Expand Down
Loading

0 comments on commit 3b8859d

Please sign in to comment.