MappingGenerator icon indicating copy to clipboard operation
MappingGenerator copied to clipboard

Generating mapping expression for C# 9 positional records

Open kszicsillag opened this issue 3 years ago • 2 comments

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 avatar Apr 02 '21 19:04 kszicsillag

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 avatar Apr 03 '21 10:04 cezarypiatek

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

cezarypiatek avatar Jun 01 '21 15:06 cezarypiatek