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

Nested complex type members are missed as flattened member sources #90

Closed
SteveWilkes opened this issue Nov 29, 2016 · 4 comments
Closed

Comments

@SteveWilkes
Copy link

Hi,

As per #89, mapping between the following members is having to be configured, instead of being found automatically by name matching:

Source:

  • Sub2
    +ProperName // <- doesn't match Sub2ProperName
  • SubWithExtraName
    +ProperName // <- doesn't match SubWithExtraNameProperName

Destination:

  • Sub2ProperName
  • SubWithExtraNameProperName

Cheers,

Steve

@chaowlert
Copy link
Collaborator

Mine is working fine, pls provide your test case.

    class Program
    {
        static void Main(string[] args)
        {
            var src = new Source
            {
                Sub2 = new SourceSub { ProperName = "A" },
                SubWithExtraName = new SourceSub { ProperName = "B" }
            };
            var dest = src.Adapt<Destination>();
            Console.WriteLine(dest.Sub2ProperName); //A
            Console.WriteLine(dest.SubWithExtraNameProperName); //B
        }
    }

    public class Source
    {
        public SourceSub Sub2 { get; set; }
        public SourceSub SubWithExtraName { get; set; }
    }

    public class SourceSub
    {
        public string ProperName { get; set; }
    }

    public class Destination
    {
        public string Sub2ProperName { get; set; }
        public string SubWithExtraNameProperName { get; set; }
    }

@SteveWilkes
Copy link
Author

SteveWilkes commented Nov 29, 2016

Here's a vs 2015 test project displaying the issue.

MapsterNestedMapping.zip

...and in case something super weird is going on - they aren't mapped when I run it! :)

null

@chaowlert
Copy link
Collaborator

Ahh, thank you for test case. If there are a lot of properties with the same prefix. Mapster will work incorrectly.

@SteveWilkes
Copy link
Author

No problem! It's easy to configure around, I just thought I'd flag it up :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants