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

UseNameSuffix for specific source and target #175

Closed
Alysaar opened this issue Nov 14, 2019 · 3 comments
Closed

UseNameSuffix for specific source and target #175

Alysaar opened this issue Nov 14, 2019 · 3 comments
Assignees

Comments

@Alysaar
Copy link

Alysaar commented Nov 14, 2019

Hi,
The documentation says that you can use UseNameSuffix and UseNamePattern for a specific source and target like so :

var anonSource = new { _PriceValue = default(double) };

Mapper.WhenMapping
    .From(anonSource)  // Apply to this anon type's mappings
    .ToANew<Product>() // Apply to Product creations
    .UseNamePattern("^_(.+)Value$"); // Match '_PriceValue' to 'Price'

However when I try it it does not seem to be implemented.

Here is an example of code that I expected to work but UseNameSuffix is not recognized :

Mapper.WhenMapping
                .From<object>()
                .To<object>()
                .UseNameSuffix("test");

Am I missing something ?
Thank you.

@SteveWilkes SteveWilkes self-assigned this Nov 14, 2019
@SteveWilkes
Copy link
Member

SteveWilkes commented Nov 24, 2019

Hi!

Thanks for raising this - apparently I missed it! You can configure type-specific naming patterns inline, but not using the static API. I'm working on it and it's proving a bit tricky, but I'll get it sorted out and will report back.

Thanks again!

Steve

@SteveWilkes
Copy link
Member

SteveWilkes commented Dec 8, 2019

Ok!

That was more complex than maybe it should have been, but it's done! The latest v1.6 branch code includes:

var anonSource = new { _PriceValue = default(double) };

Mapper.WhenMapping
    .From(anonSource)  // Apply to this anon type's mappings
    .To<Product>()       // Apply to Product mappings
    .UseNamePattern("^_(.+)Value$"); // Match '_PriceValue' to 'Price'

...release to follow. It only exists on the .From<>().To<>() API - not .From<>().ToANew<>(), etc - so you can't have different naming patterns for object creations and updates, for example.

Thanks again for pointing this out :)

Steve

@SteveWilkes SteveWilkes added the in-branch A feature or bug fix exists in code, and a release will follow label Jan 5, 2020
@SteveWilkes
Copy link
Member

UseNamePattern on the static API is included in v1.6, which is now available on NuGet.

Thanks again for the feedback!

@SteveWilkes SteveWilkes removed the in-branch A feature or bug fix exists in code, and a release will follow label Jun 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants