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
Mapping a property of custom type, inheriting from IEnumerable #635
Comments
With some debugging i can see that the difference between |
Why not use a custom type converter? |
In my real world problem i have properties of the source object that i need to construct my list, so it's not a clear cut one list to another mapping. Is this still possible with a type converter? If so, could you show me how? |
Can you modify your types to be a bit closer to what you're trying to achieve? |
I can't speak to how AutoMapper treats to/from type coercion, i.e. treating sources/destinations as |
This is roughly my scenario:
...and there are some more properties that maps between source and destination... |
It will be more rewarding if you just tried it. |
I did manage to get something working by doing a mapping like this, which seems acceptable i guess. How would you guys solve this yourselves?
|
It's a weird problem, you've got a rearranging of members. I don't know of an easy way to handle this, the names match up but are in different places. |
OK, I'm satisfied with that though. I just wanted to know if there was an obvious way to handle this that I didn't know about. The destination interface is a common type in our codebase so I created a generic typeconverter for it and with some extension methods and method chaining I've got something I can reuse pretty easily. Thanks for your time and input! |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I have a problem mapping a custom type, that inherits from an interface that in turn inherits from
IEnumerable
. I am trying to map the property using a resolver, because it has a custom constructor but i keep getting a mapping error when trying to map this. The error goes away if i take away the inheritance to IEnumerable so I assume it has something to do with this.I have created an issue for this at stack overflow.
My model looks like this:
My mappings looks like this:
The error i get looks like this:
The text was updated successfully, but these errors were encountered: