Skip to content

GH-4272: Allows ValueTypesto be used as Duplicated Fields#4274

Merged
jeremydmiller merged 4 commits intoJasperFx:masterfrom
Shield1739:duplicated_value_type_field
Apr 22, 2026
Merged

GH-4272: Allows ValueTypesto be used as Duplicated Fields#4274
jeremydmiller merged 4 commits intoJasperFx:masterfrom
Shield1739:duplicated_value_type_field

Conversation

@Shield1739
Copy link
Copy Markdown
Contributor

@Shield1739 Shield1739 commented Apr 21, 2026

Problem

ValueTypes used as Duplicated Fields would cause a compilation failure at runtime.

Issue explained in detail in: #4272

Solution

Added support for ValueType members to be used as Duplicated Fields.

  • Introduced a new DuplicatedValueTypeField class that encapsulates the ValueType-specific logic for generating correct upsert parameter code, unwrapping the inner primitive Value instead of passing the ValueType wrapper directly.
  • Updated DocumentMapping to detect when a duplicated member implements IValueTypeMember<,> and instantiate DuplicatedValueTypeField instead of the standard DuplicatedField, using the registered ValueTypeInfo from StoreOptions.ValueTypes.
  • Fixed CreateComparison(...) method to correctly handle LINQ query comparisons against duplicated ValueType fields.

Note: This solution requires the ValueType to be explicitly registered to Marten, e.g opts.RegisterValueType<T>().

Tests

  • Added tests for duplicated ValueType fields using Vogen and StronglyTypedId value objects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants