Skip to content

[MapToParent] should inherit parent's attributePrefix #149

Description

@JeremyCaney

If a binding model has [MapToParent] on a property which maps to an object with a [MapToParent] on one of its properties, that grandchild property will be prefixed with the parent's property name, but not the grandparent's property name.

Example

record Location(
  string City, 
  string State
);
record Contact(
  string Name, 
  [MapToParent] Location Location
);
record Request(
  [MapToParent] Contact PrimaryContact, 
  [MapToParent] Contact SecondaryContact
);

In this case, when Request is mapped through the ReverseTopicMappingService, it will end up with:

  • PrimaryContactName
  • LocationCity
  • LocationState
  • SecondaryContactName
  • LocationCity (collision)
  • LocationState (collision)

Instead, the [MapToParent] on Contact should inherit the attributePrefix from the parent's [MapToParent] so you end up with:

  • PrimaryContactName
  • PrimaryContactLocationCity
  • PrimaryContactLocationState
  • SecondaryContactName
  • SecondaryContactLocationCity
  • SecondaryContactLocationState

Explicit attributePrefix

This should happen even if an attributePrefix is explicitly declared on the nested [MapToParent] property. So if you had:

record Contact(
  string Name, 
  [MapToParent("")] Location Location
);

Then that should output:

  • PrimaryContactName
  • PrimaryContactCity
  • PrimaryContactState
  • SecondaryContactName
  • SecondaryContactCity
  • SecondaryContactState

Metadata

Metadata

Assignees

Labels

Area: MappingRelates to one of the `ITopicMappingService` interfaces or implementations.Priority: 0Severity 2: MajorStatus 2: ScheduledPlanned for an upcoming release.Type: BugBehavior that is inconsistent with documented or expected behavior.

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions