Skip to content

Commit

Permalink
Merge pull request #33 from Avanade/v2.0.2
Browse files Browse the repository at this point in the history
v2.0.2
  • Loading branch information
chullybun authored Jun 24, 2023
2 parents 241a9f6 + 6c68f80 commit 94f6bc8
Show file tree
Hide file tree
Showing 34 changed files with 1,168 additions and 1,312 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
dotnet-version: |
6.0.x
7.0.x
- name: Restore dependencies
run: dotnet restore
Expand Down
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.0.2
- *Enhancement:* Updated `CoreEx` (`v3.0.0`) and `DbEx` (`v2.3.5`).
- *Enhancement:* Added `net6.0` and `net7.0` support in addition to [.NET Standard](https://learn.microsoft.com/en-us/dotnet/standard/net-standard#when-to-target-net50-or-net60-vs-netstandard) to the `NTangle` package. This will allow access to additional features per version where required, and overall performance improvements.
- *Enhancement:* Included C# code-generation templates updated; target `net6.0`+ only.

## v2.0.1
- *Fixed:* `TableConfig.BatchTrackingTable` JSON serialization name corrected.
- *Fixed:* Commented Azure Service Bus event publishing code in template solution corrected.
Expand Down
5 changes: 5 additions & 0 deletions NTangle.sln
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NTangle.Template", "tools\N
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SqlServerDemo.Database", "samples\SqlServerDemo\SqlServerDemo.Database\SqlServerDemo.Database.csproj", "{467C4732-8A67-435C-9AB4-697CB89C4EE4}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Github Actions", "Github Actions", "{A06B7DBF-3FD5-452F-935D-9AFD8ADEA291}"
ProjectSection(SolutionItems) = preProject
.github\workflows\CI.yml = .github\workflows\CI.yml
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
2 changes: 1 addition & 1 deletion nuget-publish.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
Used to test locally changes, Create
.Example
C:\PS> .\nuget-publish.ps1 -NugetServer 'https://api.nuget.org/v3/index.json' -ApiKey 'key' -ProjectsToPublish @('NTangle')
C:\PS> .\nuget-publish.ps1 -NugetServer 'https://api.nuget.org/v3/index.json' -ApiKey 'key' -IncludeSymbols -IncludeSource -ProjectsToPublish @('NTangle')
Build selected pacakges and push to remote server.
#>
param(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,154 +2,147 @@
* This file is automatically generated; any changes will be lost.
*/

#nullable enable
#pragma warning disable
namespace SqlServerDemo.Publisher.Data;

namespace SqlServerDemo.Publisher.Data
/// <summary>
/// Enables the Change Data Capture (CDC) <see cref="ContactCdc"/> entity (aggregate root) orchestration (database table '[Legacy].[Contact]').
/// </summary>
public partial interface IContactOrchestrator : IEntityOrchestrator<ContactCdc> { }

/// <summary>
/// Manages the Change Data Capture (CDC) <see cref="ContactCdc"/> entity (aggregate root) orchestration (database table '[Legacy].[Contact]').
/// </summary>
public partial class ContactOrchestrator : EntityOrchestrator<ContactCdc, ContactOrchestrator.ContactCdcEnvelopeCollection, ContactOrchestrator.ContactCdcEnvelope, VersionTrackingMapper, string>, IContactOrchestrator
{
/// <summary>
/// Enables the Change Data Capture (CDC) <see cref="ContactCdc"/> entity (aggregate root) orchestration (database table '[Legacy].[Contact]').
/// </summary>
public partial interface IContactOrchestrator : IEntityOrchestrator<ContactCdc> { }
private static readonly ContactCdcMapper _contactCdcMapper = new();
private static readonly AddressCdcMapper _addressCdcMapper = new();

/// <summary>
/// Manages the Change Data Capture (CDC) <see cref="ContactCdc"/> entity (aggregate root) orchestration (database table '[Legacy].[Contact]').
/// Initializes a new instance of the <see cref="ContactOrchestrator"/> class.
/// </summary>
public partial class ContactOrchestrator : EntityOrchestrator<ContactCdc, ContactOrchestrator.ContactCdcEnvelopeCollection, ContactOrchestrator.ContactCdcEnvelope, VersionTrackingMapper, string>, IContactOrchestrator
/// <param name="db">The <see cref="IDatabase"/>.</param>
/// <param name="eventPublisher">The <see cref="IEventPublisher"/>.</param>
/// <param name="jsonSerializer">The <see cref="IJsonSerializer"/>.</param>
/// <param name="settings">The <see cref="SettingsBase"/>.</param>
/// <param name="logger">The <see cref="ILogger"/>.</param>
/// <param name="idGen">The <see cref="IIdentifierGenerator{T}"/>.</param>
public ContactOrchestrator(IDatabase db, IEventPublisher eventPublisher, IJsonSerializer jsonSerializer, SettingsBase settings, ILogger<ContactOrchestrator> logger, IIdentifierGenerator<string> idGen) :
base(db, "[NTangle].[spContactBatchExecute]", "[NTangle].[spContactBatchComplete]", eventPublisher, jsonSerializer, settings, logger, "[NTangle].[spIdentifierMappingCreate]", idGen, new IdentifierMappingMapper<string>()) => ContactOrchestratorCtor();

partial void ContactOrchestratorCtor(); // Enables additional functionality to be added to the constructor.

/// <inheritdoc/>
protected override async Task<EntityOrchestratorResult<ContactCdcEnvelopeCollection, ContactCdcEnvelope>> GetBatchEntityDataAsync(CancellationToken cancellationToken = default)
{
private static readonly ContactCdcMapper _contactCdcMapper = new ContactCdcMapper();
private static readonly AddressCdcMapper _addressCdcMapper = new AddressCdcMapper();

/// <summary>
/// Initializes a new instance of the <see cref="ContactOrchestrator"/> class.
/// </summary>
/// <param name="db">The <see cref="IDatabase"/>.</param>
/// <param name="eventPublisher">The <see cref="IEventPublisher"/>.</param>
/// <param name="jsonSerializer">The <see cref="IJsonSerializer"/>.</param>
/// <param name="settings">The <see cref="SettingsBase"/>.</param>
/// <param name="logger">The <see cref="ILogger"/>.</param>
/// <param name="idGen">The <see cref="IIdentifierGenerator{T}"/>.</param>
public ContactOrchestrator(IDatabase db, IEventPublisher eventPublisher, IJsonSerializer jsonSerializer, SettingsBase settings, ILogger<ContactOrchestrator> logger, IIdentifierGenerator<string> idGen) :
base(db, "[NTangle].[spContactBatchExecute]", "[NTangle].[spContactBatchComplete]", eventPublisher, jsonSerializer, settings, logger, "[NTangle].[spIdentifierMappingCreate]", idGen, new IdentifierMappingMapper<string>()) => ContactOrchestratorCtor();

partial void ContactOrchestratorCtor(); // Enables additional functionality to be added to the constructor.

/// <inheritdoc/>
protected override async Task<EntityOrchestratorResult<ContactCdcEnvelopeCollection, ContactCdcEnvelope>> GetBatchEntityDataAsync(CancellationToken cancellationToken = default)
{
var cColl = new ContactCdcEnvelopeCollection();
var cColl = new ContactCdcEnvelopeCollection();

var result = await SelectQueryMultiSetAsync(MultiSetArgs.Create(
// Root table: '[Legacy].[Contact]'
new MultiSetCollArgs<ContactCdcEnvelopeCollection, ContactCdcEnvelope>(_contactCdcMapper, __result => cColl = __result, stopOnNull: true),
var result = await SelectQueryMultiSetAsync(MultiSetArgs.Create(
// Root table: '[Legacy].[Contact]'
new MultiSetCollArgs<ContactCdcEnvelopeCollection, ContactCdcEnvelope>(_contactCdcMapper, __result => cColl = __result, stopOnNull: true),

// Join table: '[Legacy].[Address]' (unique name 'Address')
new MultiSetCollArgs<ContactCdc.AddressCdcCollection, ContactCdc.AddressCdc>(_addressCdcMapper, __result =>
// Join table: '[Legacy].[Address]' (unique name 'Address')
new MultiSetCollArgs<ContactCdc.AddressCdcCollection, ContactCdc.AddressCdc>(_addressCdcMapper, __result =>
{
foreach (var a in __result.GroupBy(x => new { x.AddressId }).Select(g => new { g.Key.AddressId, Coll = g.ToCollection<ContactCdc.AddressCdcCollection, ContactCdc.AddressCdc>() }))
{
foreach (var a in __result.GroupBy(x => new { x.AddressId }).Select(g => new { g.Key.AddressId, Coll = g.ToCollection<ContactCdc.AddressCdcCollection, ContactCdc.AddressCdc>() }))
{
cColl.Where(x => x.AddressId == a.AddressId).ForEach(x => x.Address = a.Coll.FirstOrDefault());
}
})), cancellationToken).ConfigureAwait(false);
cColl.Where(x => x.AddressId == a.AddressId).ForEach(x => x.Address = a.Coll.FirstOrDefault());
}
})), cancellationToken).ConfigureAwait(false);

result.Result.AddRange(cColl);
return result;
}

/// <inheritdoc/>
protected override string EventSubject => "Legacy.Contact";

result.Result.AddRange(cColl);
return result;
}
/// <inheritdoc/>
protected override EventSubjectFormat EventSubjectFormat => EventSubjectFormat.NameOnly;

/// <inheritdoc/>
protected override EventActionFormat EventActionFormat => EventActionFormat.PastTense;

/// <inheritdoc/>
protected override string? EventType => "Legacy.Contact";

/// <inheritdoc/>
protected override Uri? EventSource => new("/database/cdc/legacy/contact", UriKind.Relative);

/// <inheritdoc/>
protected override EventSourceFormat EventSourceFormat { get; } = EventSourceFormat.NameAndTableKey;

/// <summary>
/// Represents a <see cref="ContactCdc"/> envelope to append the required (additional) database properties.
/// </summary>
public class ContactCdcEnvelope : ContactCdc, IEntityEnvelope
{
/// <inheritdoc/>
protected override string EventSubject => "Legacy.Contact";
[JsonIgnore]
public CdcOperationType DatabaseOperationType { get; set; }

/// <inheritdoc/>
protected override EventSubjectFormat EventSubjectFormat => EventSubjectFormat.NameOnly;
[JsonIgnore]
public byte[] DatabaseLsn { get; set; } = Array.Empty<byte>();

/// <inheritdoc/>
protected override EventActionFormat EventActionFormat => EventActionFormat.PastTense;
[JsonIgnore]
public string? DatabaseTrackingHash { get; set; }

/// <inheritdoc/>
protected override string? EventType => "Legacy.Contact";
[JsonIgnore]
public bool IsDatabasePhysicallyDeleted { get; set; }
}

/// <summary>
/// Represents a <see cref="ContactCdcEnvelope"/> collection.
/// </summary>
public class ContactCdcEnvelopeCollection : List<ContactCdcEnvelope> { }

/// <summary>
/// Represents a <see cref="ContactCdc"/> database mapper.
/// </summary>
public class ContactCdcMapper : IDatabaseMapper<ContactCdcEnvelope>
{
/// <inheritdoc/>
protected override Uri? EventSource => new Uri("/database/cdc/legacy/contact", UriKind.Relative);
public ContactCdcEnvelope? MapFromDb(DatabaseRecord record, OperationTypes operationType) => new()
{
GlobalId = record.GetValue<string?>("GlobalId"),
CID = record.GetValue<int>("CID"),
Name = record.GetValue<string?>("Name"),
Phone = record.GetValue<string?>("Phone"),
Email = record.GetValue<string?>("Email"),
Active = record.GetValue<bool?>("Active"),
DontCallList = record.GetValue<bool?>("DontCallList"),
AddressId = record.GetValue<int?>("AddressId"),
AlternateContactId = record.GetValue<int?>("AlternateContactId"),
GlobalAlternateContactId = record.GetValue<string?>("GlobalAlternateContactId"),
UniqueId = record.GetValue<Guid>("UniqueId"),
DatabaseOperationType = record.GetValue<CdcOperationType>(CdcOperationTypeColumnName),
DatabaseLsn = record.GetValue<byte[]>(CdcLsnColumnName),
DatabaseTrackingHash = record.GetValue<string?>(TrackingHashColumnName),
IsDatabasePhysicallyDeleted = record.GetValue<bool>(IsPhysicallyDeletedColumnName)
};

/// <inheritdoc/>
protected override EventSourceFormat EventSourceFormat { get; } = EventSourceFormat.NameAndTableKey;
void IDatabaseMapper<ContactCdcEnvelope>.MapToDb(ContactCdcEnvelope? value, DatabaseParameterCollection parameters, OperationTypes operationType) => throw new NotImplementedException();
}

/// <summary>
/// Represents a <see cref="ContactCdc"/> envelope to append the required (additional) database properties.
/// </summary>
public class ContactCdcEnvelope : ContactCdc, IEntityEnvelope
{
/// <inheritdoc/>
[JsonIgnore]
public CdcOperationType DatabaseOperationType { get; set; }

/// <inheritdoc/>
[JsonIgnore]
public byte[] DatabaseLsn { get; set; }

/// <inheritdoc/>
[JsonIgnore]
public string? DatabaseTrackingHash { get; set; }

/// <inheritdoc/>
[JsonIgnore]
public bool IsDatabasePhysicallyDeleted { get; set; }
}

/// <summary>
/// Represents a <see cref="ContactCdcEnvelope"/> collection.
/// </summary>
public class ContactCdcEnvelopeCollection : List<ContactCdcEnvelope> { }

/// <summary>
/// Represents a <see cref="ContactCdc"/> database mapper.
/// </summary>
public class ContactCdcMapper : IDatabaseMapper<ContactCdcEnvelope>
{
/// <inheritdoc/>
public ContactCdcEnvelope? MapFromDb(DatabaseRecord record, OperationTypes operationType) => new ContactCdcEnvelope
{
GlobalId = record.GetValue<string?>("GlobalId"),
CID = record.GetValue<int>("CID"),
Name = record.GetValue<string?>("Name"),
Phone = record.GetValue<string?>("Phone"),
Email = record.GetValue<string?>("Email"),
Active = record.GetValue<bool?>("Active"),
DontCallList = record.GetValue<bool?>("DontCallList"),
AddressId = record.GetValue<int?>("AddressId"),
AlternateContactId = record.GetValue<int?>("AlternateContactId"),
GlobalAlternateContactId = record.GetValue<string?>("GlobalAlternateContactId"),
UniqueId = record.GetValue<Guid>("UniqueId"),
DatabaseOperationType = record.GetValue<CdcOperationType>(CdcOperationTypeColumnName),
DatabaseLsn = record.GetValue<byte[]>(CdcLsnColumnName),
DatabaseTrackingHash = record.GetValue<string?>(TrackingHashColumnName),
IsDatabasePhysicallyDeleted = record.GetValue<bool>(IsPhysicallyDeletedColumnName)
};

/// <inheritdoc/>
void IDatabaseMapper<ContactCdcEnvelope>.MapToDb(ContactCdcEnvelope? value, DatabaseParameterCollection parameters, OperationTypes operationType) => throw new NotImplementedException();
}

/// <summary>
/// Represents a <see cref="AddressCdc"/> database mapper.
/// </summary>
public class AddressCdcMapper : IDatabaseMapper<ContactCdc.AddressCdc>
/// <summary>
/// Represents a <see cref="AddressCdc"/> database mapper.
/// </summary>
public class AddressCdcMapper : IDatabaseMapper<ContactCdc.AddressCdc>
{
/// <inheritdoc/>
public ContactCdc.AddressCdc? MapFromDb(DatabaseRecord record, OperationTypes operationType) => new()
{
/// <inheritdoc/>
public ContactCdc.AddressCdc? MapFromDb(DatabaseRecord record, OperationTypes operationType) => new ContactCdc.AddressCdc
{
AddressId = record.GetValue<int>("AddressId"),
Street1 = record.GetValue<string?>("Street1"),
Street2 = record.GetValue<string?>("Street2"),
AlternateAddressId = record.GetValue<int?>("AlternateAddressId"),
GlobalAlternateAddressId = record.GetValue<string?>("GlobalAlternateAddressId")
};

/// <inheritdoc/>
void IDatabaseMapper<ContactCdc.AddressCdc>.MapToDb(ContactCdc.AddressCdc? value, DatabaseParameterCollection parameters, OperationTypes operationType) => throw new NotImplementedException();
}
}
}
AddressId = record.GetValue<int>("AddressId"),
Street1 = record.GetValue<string?>("Street1"),
Street2 = record.GetValue<string?>("Street2"),
AlternateAddressId = record.GetValue<int?>("AlternateAddressId"),
GlobalAlternateAddressId = record.GetValue<string?>("GlobalAlternateAddressId")
};

#pragma warning restore
#nullable restore
/// <inheritdoc/>
void IDatabaseMapper<ContactCdc.AddressCdc>.MapToDb(ContactCdc.AddressCdc? value, DatabaseParameterCollection parameters, OperationTypes operationType) => throw new NotImplementedException();
}
}
Loading

0 comments on commit 94f6bc8

Please sign in to comment.