Skip to content

Commit

Permalink
Merge pull request #39 from Avanade/v2.3.0
Browse files Browse the repository at this point in the history
v2.3.0
  • Loading branch information
chullybun authored Aug 17, 2023
2 parents fc5a3f3 + 73361d7 commit a9b8452
Show file tree
Hide file tree
Showing 83 changed files with 303 additions and 241 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.3.0
- *Enhancement:* Separated the code-generation tooling logic out into a separate package `NTangle.CodeGen` as this is not required to be deployed with the underlying runtime logic. This is a **breaking change**, in that previous references will need to be updated to the new package.
- *Enhancement:* The version tracking table has had a timestamp column added.
- *Fixed:* Entity code-generation now correctly references the actual underlying table name versus the alias.

## v2.2.3
- *Fixed:* Joins without `IdentifierMapping` were incorrectly generated with mapping code where the root table has mapping, and the joined table did not. The `GlobalId` JSON name can now also be renamed.

Expand Down
41 changes: 41 additions & 0 deletions Common.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<Project>
<PropertyGroup>
<Version>2.3.0</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>NTangle Developers</Authors>
<Company>Avanade</Company>
<LangVersion>preview</LangVersion>
<Copyright>Avanade (c)</Copyright>
<PackageProjectUrl>https://github.com/Avanade/NTangle</PackageProjectUrl>
<RepositoryUrl>https://github.com/Avanade/NTangle</RepositoryUrl>
<Product>NTangle</Product>
<SignAssembly>true</SignAssembly>
<DelaySign>false</DelaySign>
<AssemblyOriginatorKeyFile>strong-name-key.snk</AssemblyOriginatorKeyFile>
<PackageIconUrl>https://github.com/Avanade/NTangle/raw/main/images/Logo256x256.png</PackageIconUrl>
<PackageIcon>Logo256x256.png</PackageIcon>
<RepositoryType>git</RepositoryType>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<RunAnalyzersDuringBuild>true</RunAnalyzersDuringBuild>
<Nullable>enable</Nullable>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<IncludeSymbols>true</IncludeSymbols>
<EmbedAllSources>true</EmbedAllSources>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors />
</PropertyGroup>

<ItemGroup>
<None Include="..\..\images\Logo256x256.png" Link="Logo256x256.png">
<PackagePath>\</PackagePath>
<Pack>true</Pack>
</None>
</ItemGroup>
</Project>
8 changes: 8 additions & 0 deletions NTangle.sln
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.gitignore = .gitignore
CHANGELOG.md = CHANGELOG.md
CODE_OF_CONDUCT.md = CODE_OF_CONDUCT.md
Common.targets = Common.targets
CONTRIBUTING.md = CONTRIBUTING.md
LICENSE = LICENSE
nuget-publish.ps1 = nuget-publish.ps1
Expand Down Expand Up @@ -90,6 +91,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{7596959A-8
samples\ContactSync\docs\old-app-setup.md = samples\ContactSync\docs\old-app-setup.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NTangle.CodeGen", "tools\NTangle.CodeGen\NTangle.CodeGen.csproj", "{BB87378A-0444-4BDC-8530-20F25D852C77}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -148,6 +151,10 @@ Global
{D6364CFB-DAAA-41E7-996F-8F1654EECF10}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D6364CFB-DAAA-41E7-996F-8F1654EECF10}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D6364CFB-DAAA-41E7-996F-8F1654EECF10}.Release|Any CPU.Build.0 = Release|Any CPU
{BB87378A-0444-4BDC-8530-20F25D852C77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BB87378A-0444-4BDC-8530-20F25D852C77}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BB87378A-0444-4BDC-8530-20F25D852C77}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BB87378A-0444-4BDC-8530-20F25D852C77}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -171,6 +178,7 @@ Global
{4BADE51C-EA1C-4A68-B591-8F148F5FF975} = {6855FFC2-39E7-48D4-AB5D-079D406390FC}
{D6364CFB-DAAA-41E7-996F-8F1654EECF10} = {6855FFC2-39E7-48D4-AB5D-079D406390FC}
{7596959A-8A5E-409D-BED5-006950299A4E} = {240EFA31-7366-47BD-8A56-B3312D06BB13}
{BB87378A-0444-4BDC-8530-20F25D852C77} = {780B69CA-D467-45CF-B115-A3FEB0B88BD1}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B97E5639-3430-4AD7-9942-D35EF26F263B}
Expand Down
1 change: 1 addition & 0 deletions nuget-publish.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ param(
[string]$NugetCacheFolder = "$($env:USERPROFILE)\.nuget\packages",
[String[]]$ProjectsToPublish = @(
"src\NTangle",
"tools\NTangle.CodeGen",
"tools\NTangle.Template")
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\src\NTangle\NTangle.csproj" />
<ProjectReference Include="..\..\..\..\tools\NTangle.CodeGen\NTangle.CodeGen.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="ntangle.yaml">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using NTangle.Console;
using NTangle.CodeGen;
using System.Threading.Tasks;

namespace ContactSync.OldApp.CodeGen;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\..\src\NTangle\NTangle.csproj" />
<PackageReference Include="DbEx.SqlServer" Version="2.3.7" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ CREATE TABLE [NTangle].[VersionTracking] (
[Table] VARCHAR(127) NOT NULL,
[Key] NVARCHAR(255) NOT NULL,
[Hash] NVARCHAR(127) NOT NULL,
[Timestamp] DATETIME2 NOT NULL,
[BatchTrackingId] BIGINT NOT NULL,
CONSTRAINT [IX_NTangle_VersionTracking_SchemaTableKey] UNIQUE CLUSTERED ([Schema], [Table], [Key])
);
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ BEGIN
THROW 56002, @Msg, 1;
END

DECLARE @Timestamp DATETIME2
SET @Timestamp = GETUTCDATE()

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

Expand All @@ -44,10 +47,10 @@ BEGIN
SELECT [_list].[Key], [_list].[Hash]
EXCEPT
SELECT [_vt].[Key], [_vt].[Hash])
THEN UPDATE SET [_vt].[Hash] = [_list].[Hash], [_vt].[BatchTrackingId] = @BatchTrackingId
THEN UPDATE SET [_vt].[Hash] = [_list].[Hash], [_vt].[Timestamp] = @Timestamp, [_vt].[BatchTrackingId] = @BatchTrackingId
WHEN NOT MATCHED BY TARGET
THEN INSERT ([Schema], [Table], [Key], [Hash], [BatchTrackingId])
VALUES (N'old', N'Contact', [_list].[Key], [_list].[Hash], @BatchTrackingId);
THEN INSERT ([Schema], [Table], [Key], [Hash], [Timestamp], [BatchTrackingId])
VALUES (N'old', N'Contact', [_list].[Key], [_list].[Hash], @Timestamp, @BatchTrackingId);

SELECT [_batch].[BatchTrackingId], [_batch].[CreatedDate], [_batch].[IsComplete], [_batch].[CompletedDate], [_batch].[CorrelationId], [_batch].[HasDataLoss]
FROM [NTangle].[ContactBatchTracking] AS [_batch]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,48 @@
namespace ContactSync.OldApp.Publisher.Entities;

/// <summary>
/// Represents the CDC model for the root (parent) database table '[old].[Contact]'.
/// Represents the CDC model for the root (parent) database table '[old].[contact]'.
/// </summary>
public partial class ContactCdc : IEntity
{
/// <summary>
/// Gets or sets the Id '[old].[Contact].[contact_id]' column value.
/// Gets or sets the Id '[old].[contact].[contact_id]' column value.
/// </summary>
[JsonPropertyName("id")]
public int Id { get; set; }

/// <summary>
/// Gets or sets the Name '[old].[Contact].[contact_name]' column value.
/// Gets or sets the Name '[old].[contact].[contact_name]' column value.
/// </summary>
[JsonPropertyName("name")]
public string? Name { get; set; }

/// <summary>
/// Gets or sets the Phone '[old].[Contact].[contact_phone]' column value.
/// Gets or sets the Phone '[old].[contact].[contact_phone]' column value.
/// </summary>
[JsonPropertyName("phone")]
public string? Phone { get; set; }

/// <summary>
/// Gets or sets the Email '[old].[Contact].[contact_email]' column value.
/// Gets or sets the Email '[old].[contact].[contact_email]' column value.
/// </summary>
[JsonPropertyName("email")]
public string? Email { get; set; }

/// <summary>
/// Gets or sets the Is Active '[old].[Contact].[contact_active]' column value.
/// Gets or sets the Is Active '[old].[contact].[contact_active]' column value.
/// </summary>
[JsonPropertyName("isActive")]
public bool? IsActive { get; set; }

/// <summary>
/// Gets or sets the No Call List '[old].[Contact].[contact_no_calling]' column value.
/// Gets or sets the No Call List '[old].[contact].[contact_no_calling]' column value.
/// </summary>
[JsonPropertyName("noCallList")]
public bool? NoCallList { get; set; }

/// <summary>
/// Gets or sets the Contact Addressid '[old].[Contact].[contact_addressid]' column value.
/// Gets or sets the Contact Addressid '[old].[contact].[contact_addressid]' column value.
/// </summary>
[JsonIgnore]
public int? ContactAddressid { get; set; }
Expand All @@ -73,19 +73,19 @@ public partial class ContactCdc : IEntity
public partial class AddressCdc : IPrimaryKey
{
/// <summary>
/// Gets or sets the Id '[old].[Address].[contact_address_id]' column value. This column is used within the join.
/// Gets or sets the Id '[old].[contact_address].[contact_address_id]' column value. This column is used within the join.
/// </summary>
[JsonIgnore]
public int Id { get; set; }

/// <summary>
/// Gets or sets the Street1 '[old].[Address].[address_street_1]' column value.
/// Gets or sets the Street1 '[old].[contact_address].[address_street_1]' column value.
/// </summary>
[JsonPropertyName("street1")]
public string? Street1 { get; set; }

/// <summary>
/// Gets or sets the Street2 '[old].[Address].[address_street_2]' column value.
/// Gets or sets the Street2 '[old].[contact_address].[address_street_2]' column value.
/// </summary>
[JsonPropertyName("street2")]
public string? Street2 { get; set; }
Expand All @@ -96,7 +96,7 @@ public partial class AddressCdc : IPrimaryKey
}

/// <summary>
/// Represents the CDC model collection for the related (child) database table '[old].[Address]'.
/// Represents the CDC model collection for the related (child) database table '[old].[contact_address]'.
/// </summary>
public partial class AddressCdcCollection : List<AddressCdc> { }

Expand Down
2 changes: 1 addition & 1 deletion samples/SqlServerDemo/SqlServerDemo.CodeGen/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using NTangle.Console;
using NTangle.CodeGen;
using System.Threading.Tasks;

namespace SqlServerDemo.CodeGen;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\NTangle\NTangle.csproj" />
<ProjectReference Include="..\..\..\tools\NTangle.CodeGen\NTangle.CodeGen.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ CREATE TABLE [NTangle].[VersionTracking] (
[Table] VARCHAR(127) NOT NULL,
[Key] NVARCHAR(255) NOT NULL,
[Hash] NVARCHAR(127) NOT NULL,
[Timestamp] DATETIME2 NOT NULL,
[BatchTrackingId] BIGINT NOT NULL,
CONSTRAINT [IX_NTangle_VersionTracking_SchemaTableKey] UNIQUE CLUSTERED ([Schema], [Table], [Key])
);
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ BEGIN
THROW 56002, @Msg, 1;
END

DECLARE @Timestamp DATETIME2
SET @Timestamp = GETUTCDATE()

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

Expand All @@ -44,10 +47,10 @@ BEGIN
SELECT [_list].[Key], [_list].[Hash]
EXCEPT
SELECT [_vt].[Key], [_vt].[Hash])
THEN UPDATE SET [_vt].[Hash] = [_list].[Hash], [_vt].[BatchTrackingId] = @BatchTrackingId
THEN UPDATE SET [_vt].[Hash] = [_list].[Hash], [_vt].[Timestamp] = @Timestamp, [_vt].[BatchTrackingId] = @BatchTrackingId
WHEN NOT MATCHED BY TARGET
THEN INSERT ([Schema], [Table], [Key], [Hash], [BatchTrackingId])
VALUES (N'Legacy', N'Contact', [_list].[Key], [_list].[Hash], @BatchTrackingId);
THEN INSERT ([Schema], [Table], [Key], [Hash], [Timestamp], [BatchTrackingId])
VALUES (N'Legacy', N'Contact', [_list].[Key], [_list].[Hash], @Timestamp, @BatchTrackingId);

SELECT [_batch].[BatchTrackingId], [_batch].[CreatedDate], [_batch].[IsComplete], [_batch].[CompletedDate], [_batch].[CorrelationId], [_batch].[HasDataLoss]
FROM [NTangle].[ContactBatchTracking] AS [_batch]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ BEGIN
THROW 56002, @Msg, 1;
END

DECLARE @Timestamp DATETIME2
SET @Timestamp = GETUTCDATE()

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

Expand All @@ -44,10 +47,10 @@ BEGIN
SELECT [_list].[Key], [_list].[Hash]
EXCEPT
SELECT [_vt].[Key], [_vt].[Hash])
THEN UPDATE SET [_vt].[Hash] = [_list].[Hash], [_vt].[BatchTrackingId] = @BatchTrackingId
THEN UPDATE SET [_vt].[Hash] = [_list].[Hash], [_vt].[Timestamp] = @Timestamp, [_vt].[BatchTrackingId] = @BatchTrackingId
WHEN NOT MATCHED BY TARGET
THEN INSERT ([Schema], [Table], [Key], [Hash], [BatchTrackingId])
VALUES (N'Legacy', N'Customer', [_list].[Key], [_list].[Hash], @BatchTrackingId);
THEN INSERT ([Schema], [Table], [Key], [Hash], [Timestamp], [BatchTrackingId])
VALUES (N'Legacy', N'Customer', [_list].[Key], [_list].[Hash], @Timestamp, @BatchTrackingId);

SELECT [_batch].[BatchTrackingId], [_batch].[CreatedDate], [_batch].[IsComplete], [_batch].[CompletedDate], [_batch].[CorrelationId], [_batch].[HasDataLoss]
FROM [NTangle].[CustomerBatchTracking] AS [_batch]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ BEGIN
THROW 56002, @Msg, 1;
END

DECLARE @Timestamp DATETIME2
SET @Timestamp = GETUTCDATE()

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

Expand All @@ -44,10 +47,10 @@ BEGIN
SELECT [_list].[Key], [_list].[Hash]
EXCEPT
SELECT [_vt].[Key], [_vt].[Hash])
THEN UPDATE SET [_vt].[Hash] = [_list].[Hash], [_vt].[BatchTrackingId] = @BatchTrackingId
THEN UPDATE SET [_vt].[Hash] = [_list].[Hash], [_vt].[Timestamp] = @Timestamp, [_vt].[BatchTrackingId] = @BatchTrackingId
WHEN NOT MATCHED BY TARGET
THEN INSERT ([Schema], [Table], [Key], [Hash], [BatchTrackingId])
VALUES (N'Legacy', N'Posts', [_list].[Key], [_list].[Hash], @BatchTrackingId);
THEN INSERT ([Schema], [Table], [Key], [Hash], [Timestamp], [BatchTrackingId])
VALUES (N'Legacy', N'Posts', [_list].[Key], [_list].[Hash], @Timestamp, @BatchTrackingId);

SELECT [_batch].[BatchTrackingId], [_batch].[CreatedDate], [_batch].[IsComplete], [_batch].[CompletedDate], [_batch].[CorrelationId], [_batch].[HasDataLoss]
FROM [NTangle].[PostsBatchTracking] AS [_batch]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\NTangle\NTangle.csproj" />
<PackageReference Include="DbEx.SqlServer" Version="2.3.7" />
</ItemGroup>

</Project>
Loading

0 comments on commit a9b8452

Please sign in to comment.