You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Assert.Equal("[Warning] Architect.DomainModeling.Tests.EntityFramework.ValueObjectForEF.One uses OrdinalIgnoreCase comparisons, but the default SQLite database collation acts more like Ordinal - use the options in ConfigureIdentityConventions() and ConfigureWrapperValueObjectConventions() to specify default collations, or configure property collations manually",warning);
102
+
103
+
// The logs should show that certain collations were set
104
+
Assert.Contains(logs, log =>log.Equals("[Debug] Set collation BINARY for SomeStringId properties based on the type's case-sensitivity"));
105
+
Assert.Contains(logs, log =>log.Equals("[Debug] Set collation NOCASE for EntityForEFId properties based on the type's case-sensitivity"));
[SuppressMessage("CodeQuality","IDE0079:Remove unnecessary suppression",Justification="Suppression is necessary.")]
116
+
[SuppressMessage("Usage","CA2263:Prefer generic overload when type is known",Justification="We have no generic info for types received from callbacks.")]
/// If specified, this collation is set on configured <see langword="string"/> <see cref="IIdentity{T}"/> types that use <see cref="StringComparison.Ordinal"/>.
11
+
/// </para>
12
+
/// <para>
13
+
/// This helps the database column match the model's behavior.
14
+
/// </para>
15
+
/// </summary>
16
+
publicstring?CaseSensitiveCollation{get;init;}
17
+
18
+
/// <summary>
19
+
/// <para>
20
+
/// If specified, this collation is set on configured <see langword="string"/> <see cref="IIdentity{T}"/> types that use <see cref="StringComparison.OrdinalIgnoreCase"/>.
21
+
/// </para>
22
+
/// <para>
23
+
/// This helps the database column match the model's behavior.
Copy file name to clipboardExpand all lines: DomainModeling/DomainModeling.csproj
+6-2Lines changed: 6 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -37,15 +37,19 @@ Release notes:
37
37
Platform support:
38
38
- BREAKING: Platform support: Dropped support for .NET 6.0 and .NET 7.0 (EOL).
39
39
40
-
The base class is dead. Long live the interface!
41
-
42
40
Completed support for nested wrappers:
43
41
- Feature: Nested WrapperValueObject/Identity types can now also wrap/unwrap and serialize/deserialize directly to/from their core (deepest) underlying type.
44
42
- Feature: EF conversions for such types now automatically map to and from the core type.
45
43
- Feature: A deeper underlying type can be simulated, e.g. LazyStringId : IIdentity<Lazy<string>>, ICoreValueWrapper<LazyStringId, string>.
46
44
- BREAKING: ISerializableDomainObject is deprecated in favor of IValueWrapper, a clear and comprehensive type to represented generic value wrappers.
47
45
- BREAKING: IIdentityConfigurator and IWrapperValueObjectConfigurator now receive an additional type parameter on their methods, namely the core type.
48
46
47
+
Correct string comparisons with EF:
48
+
- Feature: ConfigureIdentityConventions()/ConfigureWrapperValueObjectConventions() now set a PROVIDER value comparer for each string wrapper property, matching the type's case-sensitivity. Since EF Core 7, EF compares keys using the provider type instead of the model type.
49
+
- Feature: ConfigureIdentityConventions()/ConfigureWrapperValueObjectConventions() now warn if a string wrapper property has a collation mismatching the type's case-sensitivity, unless collation was explicitly chosen.
50
+
- Feature: ConfigureIdentityConventions()/ConfigureWrapperValueObjectConventions() now take an optional "options" parameter, which allows specifying the respective collations for case-sensitive vs. ignore-case string wrappers.
51
+
- Feature: ConfigureDomainModelConventions() now has convenience extension methods CustomizeIdentityConventions()/CustomizeWrapperValueObjectConventions(), for easy custom conventions, such as based on the core underlying type.
52
+
49
53
Performance:
50
54
- Enhancement: Reduced assembly size by having source-generated WrapperValueObject/Identity types use generic JSON serializers instead of generating their own.
Copy file name to clipboardExpand all lines: README.md
+27-1Lines changed: 27 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -371,27 +371,53 @@ internal sealed class MyDbContext : DbContext
371
371
{
372
372
// Snip
373
373
374
+
[SuppressMessage("CodeQuality", "IDE0079:Remove unnecessary suppression", Justification="Suppression is necessary.")]
375
+
[SuppressMessage("Usage", "CA2263:Prefer generic overload when type is known", Justification="We have no generic info for types received from callbacks.")]
`ConfigureDomainModelConventions()` itself does not have any effect other than to invoke its action, which allows the specific mapping kinds to be chosen.
391
416
The inner calls, such as to `ConfigureIdentityConventions()`, configure the various conventions.
417
+
The `Customize*()` methods make it easy to specify your own conventions, such as for every identity or wrapper value object with a string at its core.
392
418
393
419
Thanks to the provided conventions, no manual boilerplate mappings are needed, like conversions to primitives.
394
-
The developer need only write meaningful mappings, such as the maximum length of a string property.
420
+
Property-specific mappings are only needed where they are meaningful, such as the maximum length of a particular string property.
395
421
396
422
Since only conventions are registered, regular mappings can override any part of the provided behavior.
0 commit comments