Skip to content
This repository has been archived by the owner on Jan 16, 2022. It is now read-only.

Generating mapping expression for C# 9 positional records #170

Open
kszicsillag opened this issue Apr 2, 2021 · 2 comments
Open

Generating mapping expression for C# 9 positional records #170

kszicsillag opened this issue Apr 2, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@kszicsillag
Copy link

Feature description
I am trying to generate mapping expressions between EF entity model and a DTO model. The DTO model consists of C#9 positional records. I could not generate proper DTO constructor for these expressions using any generation option.

The scenario is same as below, except filling a multi-parameter constructor instead of an initialization block as C# 9 positional records are initialized through constructor instead of initialization block.
initialization block in lambda expression

Reasoning behind
Generating expressions do work for initialization blocks. Generating pure mapping methods do work with positional records as mapping target. Generating expressions for positional records should work as well.

Real word example of the usage
Positional record is an emerging new concept, expecting to see more DTO models implemented as positional records.

@kszicsillag kszicsillag added the enhancement New feature or request label Apr 2, 2021
@cezarypiatek
Copy link
Owner

Hi @kszicsillag

Thanks for reporting this feature request. I will try to implement it but right now I can't promise any specific date. I will let you know when it's ready.

@cezarypiatek
Copy link
Owner

cezarypiatek commented Jun 1, 2021

Hi @kszicsillag

This refactoring option is not using the constructor because it's strictly intended for completing the initialization blocks.
In the case of regular mapping, a record primer constructor should be automatically picked up.

The new version of MappingGenerator contains a refactoring for generating this kind of lambda expression from the scratch.
6glQjkHLPn

If you have other problems with record types or any suggestion please report them in the new issue tracker https://github.com/cezarypiatek/MappingGeneratorIssueTracker

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants