Skip to content

Commit dee56a9

Browse files
authored
v3.31.0 (#136)
* `JsonMergePatch` enhancements. * - *Enhancement:* Refactored the `CosmosDb` capabilities such that the `CosmosDbContainer` and `CosmosDbModelContainer` are model type independent, with underlying type support implemented at the method level for greater flexibility and control. The typed `CosmosDbContainer<T, TModel>` etc. remain and are accessed from the type independent containers as required. - The existing `IMultiSetArgs` operations have been moved (and renamed) from `CosmosDb` to `CosmosDbContainer` and `CosmosDbModelContainer` as these are single container-specific. - The existing `CosmosDb.UseAuthorizeFilter` operations have been moved to `CosmosDbContainer` as these are single container-specific. * - *Enhancement:* Added `Cleaner.PrepareCreate` and `Cleaner.PrepareUpdate` to encapsulate `ChangeLog.PrepareCreated` and `ChangeLog.PrepareUpdated`, and `Cleaner.ResetTenantId` to ensure consistent handling throughout _CoreEx_. - *Enhancement:* Added `SystemTime.Timestamp` as the standard means to access the current timestamp (uses `Cleaner.Clean`) to ensure consistency throughout _CoreEx_. Therefore, the likes of `DateTime.UtcNow` should be replaced with `SystemTime.Timestamp`. The previous `ExecutionContent.SystemTime` has been removed as it was not consistent with the `ExecutionContext` pattern. * - *Enhancement:* Updated the `IExtendedException.ShouldBeLogged` implementations to check `SettingsBase` configuration to enable/disable. * - Simply CosmosDB configuration; removes need for lazy instantiation - Update packages * ICU fix? * ICU again? * ICU again? * ICU again? * ICU again * ICU again? * ICU again? * ICU again? * ICU again? * ICU again?
1 parent 366165a commit dee56a9

File tree

138 files changed

+6975
-2805
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+6975
-2805
lines changed

.github/workflows/CI.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ jobs:
4040
uses: actions/setup-dotnet@v1
4141
with:
4242
dotnet-version: |
43-
3.1.x
4443
6.0.x
4544
8.0.x
4645
9.0.x

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
Represents the **NuGet** versions.
44

5+
## v3.31.0
6+
- *Enhancement:* Moved existing reflection-based `JsonMergePatch` to `Extended.JsonMergePatchEx`; this remains the `AddJsonMergePatch` default implementation.
7+
- *Enhancement:* Added new `JsonMergePatch` that leverages `JsonElement` and `Utf8JsonWriter` without underlying reflection; useful in scenarios where the value type is not known. This is also not as performant as the reflection-based `JsonMergePatchEx` version and the primary reason why it is not the new default.
8+
- *Enhancement:* Refactored the `CosmosDb` capabilities such that the `CosmosDbContainer` and `CosmosDbModelContainer` are model type independent, with underlying type support implemented at the method level for greater flexibility and control. The typed `CosmosDbContainer<T, TModel>` etc. remain and are accessed from the type independent containers as required.
9+
- The existing `IMultiSetArgs` operations have been moved (and renamed) from `CosmosDb` to `CosmosDbContainer` and `CosmosDbModelContainer` as these are single container-specific.
10+
- The existing `CosmosDb.UseAuthorizeFilter` operations have been moved to `CosmosDbContainer` as these are single container-specific.
11+
- *Enhancement:* Added `Cleaner.PrepareCreate` and `Cleaner.PrepareUpdate` to encapsulate `ChangeLog.PrepareCreated` and `ChangeLog.PrepareUpdated`, and `Cleaner.ResetTenantId` to ensure consistent handling throughout _CoreEx_.
12+
- *Enhancement:* Added `SystemTime.Timestamp` as the standard means to access the current timestamp (uses `Cleaner.Clean`) to ensure consistency throughout _CoreEx_. Therefore, the likes of `DateTime.UtcNow` should be replaced with `SystemTime.Timestamp`. The previous `ExecutionContent.SystemTime` has been removed as it was not consistent with the `ExecutionContext` pattern.
13+
- *Enhancement:* Updated the `IExtendedException.ShouldBeLogged` implementations to check `SettingsBase` configuration to enable/disable.
14+
- *Enhancement:* Updated dependencies to latest; including transitive where applicable.
15+
516
## v3.30.2
617
- *Fixed:* Missing `QueryArgs.IncludeText` added to set the `$text=true` equivalent.
718
- *Fixed:* Simplification of creating and setting the `QueryArgs.Filter` using an implict string operator.

Common.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
3-
<Version>3.30.2</Version>
3+
<Version>3.31.0</Version>
44
<LangVersion>preview</LangVersion>
55
<Authors>Avanade</Authors>
66
<Company>Avanade</Company>

samples/My.Hr/My.Hr.Api/Startup.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using CoreEx.Azure.ServiceBus.HealthChecks;
99
using Azure.Messaging.ServiceBus;
1010
using Microsoft.Extensions.DependencyInjection;
11+
using CoreEx.Json.Merge;
1112

1213
namespace My.Hr.Api;
1314

@@ -34,7 +35,7 @@ public void ConfigureServices(IServiceCollection services)
3435
.AddAzureServiceBusSender()
3536
.AddAzureServiceBusPurger()
3637
.AddJsonMergePatch()
37-
.AddWebApi((_, webapi) => webapi.UnhandledExceptionAsync = (ex, _, _) => Task.FromResult(ex is DbUpdateConcurrencyException efex ? webapi.CreateActionResultFromExtendedException(new ConcurrencyException()) : null))
38+
.AddWebApi((_, webapi) => webapi.UnhandledExceptionAsync = (ex, logger, _) => Task.FromResult(ex is DbUpdateConcurrencyException efex ? webapi.CreateActionResultFromExtendedException(new ConcurrencyException(null, ex), logger) : null))
3839
.AddReferenceDataContentWebApi()
3940
.AddRequestCache();
4041

samples/My.Hr/My.Hr.Api/appsettings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"AbsoluteExpirationRelativeToNow": "03:00:00",
1616
"SlidingExpiration": "00:45:00"
1717
}
18-
}
18+
},
19+
"LogConcurrencyException": true
1920
},
2021
"ServiceBusConnection": {
2122
"fullyQualifiedNamespace": "Endpoint=sb://top-secret.servicebus.windows.net/;SharedAccessKeyName=top-secret;SharedAccessKey=top-encrypted-secret"
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
namespace My.Hr.Business.Data;
2+
3+
public class Employee2Configuration : IEntityTypeConfiguration<Employee2>
4+
{
5+
public void Configure(EntityTypeBuilder<Employee2> builder)
6+
{
7+
builder.ToTable("Employee2", "Hr");
8+
builder.Property(p => p.Id).HasColumnName("EmployeeId").HasColumnType("UNIQUEIDENTIFIER");
9+
builder.Property(p => p.Email).HasColumnType("NVARCHAR(250)");
10+
builder.Property(p => p.FirstName).HasColumnType("NVARCHAR(100)");
11+
builder.Property(p => p.LastName).HasColumnType("NVARCHAR(100)");
12+
builder.Property(p => p.Gender).HasColumnName("GenderCode").HasColumnType("NVARCHAR(50)").HasConversion(v => v!.Code, v => (Gender?)v);
13+
builder.Property(p => p.Birthday).HasColumnType("DATE");
14+
builder.Property(p => p.StartDate).HasColumnType("DATE");
15+
builder.Property(p => p.TerminationDate).HasColumnType("DATE");
16+
builder.Property(p => p.TerminationReasonCode).HasColumnType("NVARCHAR(50)");
17+
builder.Property(p => p.PhoneNo).HasColumnType("NVARCHAR(50)");
18+
builder.Property(p => p.ETag).HasColumnName("RowVersion").IsRowVersion().HasConversion(s => s == null ? Array.Empty<byte>() : Convert.FromBase64String(s), d => Convert.ToBase64String(d));
19+
builder.Property(p => p.IsDeleted).HasColumnType("BIT");
20+
builder.HasKey("Id");
21+
}
22+
}

samples/My.Hr/My.Hr.Business/Data/HrDbContext.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
1818
{
1919
modelBuilder
2020
.ApplyConfiguration(new UsStateConfiguration())
21-
.ApplyConfiguration(new EmployeeConfiguration());
21+
.ApplyConfiguration(new EmployeeConfiguration())
22+
.ApplyConfiguration(new Employee2Configuration());
2223

2324
base.OnModelCreating(modelBuilder);
2425
}

samples/My.Hr/My.Hr.Business/Data/HrEfDb.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ public interface IHrEfDb : IEfDb
99
/// Gets the <see cref="Employee"/> entity.
1010
/// </summary>
1111
EfDbEntity<Employee, Employee> Employees { get; }
12+
13+
/// <summary>
14+
/// Gets the <see cref="Employee2"/> entity.
15+
/// </summary>
16+
EfDbEntity<Employee2, Employee2> Employees2 { get; }
1217
}
1318

1419
/// <summary>
@@ -27,5 +32,10 @@ public HrEfDb(HrDbContext dbContext, IMapper mapper) : base(dbContext, mapper) {
2732
/// Gets the <see cref="Employee"/> encapsulated entity.
2833
/// </summary>
2934
public EfDbEntity<Employee, Employee> Employees => new(this);
35+
36+
/// <summary>
37+
/// Gets the <see cref="Employee"/> encapsulated entity.
38+
/// </summary>
39+
public EfDbEntity<Employee2, Employee2> Employees2 => new(this);
3040
}
3141
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
using System.Diagnostics;
2+
3+
namespace My.Hr.Business.Models;
4+
5+
/// <summary>
6+
/// Represents the Entity Framework (EF) model for database object 'Hr.Employee2'.
7+
/// </summary>
8+
public class Employee2 : IIdentifier<Guid>, IETag, ILogicallyDeleted
9+
{
10+
/// <summary>
11+
/// Gets or sets the 'EmployeeId' column value.
12+
/// </summary>
13+
public Guid Id { get; set; }
14+
15+
/// <summary>
16+
/// Gets or sets the 'Email' column value.
17+
/// </summary>
18+
public string? Email { get; set; }
19+
20+
/// <summary>
21+
/// Gets or sets the 'FirstName' column value.
22+
/// </summary>
23+
public string? FirstName { get; set; }
24+
25+
/// <summary>
26+
/// Gets or sets the 'LastName' column value.
27+
/// </summary>
28+
public string? LastName { get; set; }
29+
30+
/// <summary>
31+
/// Gets or sets the 'GenderCode' column value.
32+
/// </summary>
33+
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
34+
public Gender? Gender { get; set; }
35+
36+
/// <summary>
37+
/// Gets or sets the 'Birthday' column value.
38+
/// </summary>
39+
public DateTime? Birthday { get; set; }
40+
41+
/// <summary>
42+
/// Gets or sets the 'StartDate' column value.
43+
/// </summary>
44+
public DateTime? StartDate { get; set; }
45+
46+
/// <summary>
47+
/// Gets or sets the 'TerminationDate' column value.
48+
/// </summary>
49+
public DateTime? TerminationDate { get; set; }
50+
51+
/// <summary>
52+
/// Gets or sets the 'TerminationReasonCode' column value.
53+
/// </summary>
54+
public string? TerminationReasonCode { get; set; }
55+
56+
/// <summary>
57+
/// Gets or sets the 'PhoneNo' column value.
58+
/// </summary>
59+
public string? PhoneNo { get; set; }
60+
61+
/// <summary>
62+
/// Gets or sets the 'RowVersion' column value.
63+
/// </summary>
64+
public string? ETag { get; set; }
65+
66+
/// <summary>
67+
/// Gets or sets the 'IsDeleted' column value.
68+
/// </summary>
69+
public bool? IsDeleted { get; set; }
70+
}
71+
72+
public class Employee2Collection : List<Employee2> { }
73+
74+
public class Employee2CollectionResult : CollectionResult<Employee2Collection, Employee2> { }

samples/My.Hr/My.Hr.Business/Services/EmployeeResultService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public Task<Result> VerifyEmployeeAsync(Guid id) => Result
3636
var verification = new EmployeeVerificationRequest
3737
{
3838
Name = employee!.FirstName,
39-
Age = DateTime.UtcNow.Subtract(employee.Birthday.GetValueOrDefault()).Days / 365,
39+
Age = SystemTime.Timestamp.Subtract(employee.Birthday.GetValueOrDefault()).Days / 365,
4040
Gender = employee.Gender?.Code
4141
};
4242

0 commit comments

Comments
 (0)