Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support mapping multiple columns into a single value object property in query source generator #55

Open
montyclt opened this issue Mar 21, 2025 · 0 comments
Labels
area-persistence Related to persistence, queries, repositories, uow and entities

Comments

@montyclt
Copy link
Member

montyclt commented Mar 21, 2025

Description

Currently, the query source generator only supports mapping single columns to properties. However, there are cases where we need to map multiple columns into a single value object property, especially when dealing with value objects that encapsulate related data.

For example, when mapping person names into a PersonName value object:

-- // Current approach (multiple result properties):
-- @result string given_name
-- @result string family_name

-- // Desired approach (single value object property):
-- @result PersonName name { given_name, family_name }

SELECT 
    person.given_name,
    person.family_name
FROM people

Use Cases

  1. Name-related fields (given name, family name)
  2. Address components (street, city, postal code)
  3. Geographic coordinates (latitude, longitude)
  4. Money values (amount, currency)
  5. Time ranges (start, end)

Proposed Syntax

-- @result MyNamespace.ValueObject property_name { column1, column2, ... }

Where:

  • MyNamespace.ValueObject is the fully qualified type name
  • property_name is the name of the property in the result object in snake_case. It should transform to CamelCase automatically
  • { column1, column2, ... } are the column names

Note on NHibernate Implementation

When using the NHibernate implementation, these value objects are mapped using ICompositeUserType. This interface allows NHibernate to handle the mapping of multiple columns into a single value object.

@montyclt montyclt added the area-persistence Related to persistence, queries, repositories, uow and entities label Mar 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-persistence Related to persistence, queries, repositories, uow and entities
Projects
None yet
Development

No branches or pull requests

1 participant