-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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 more that two objects into one #389
Comments
You can do this, but configuration validation won't work. It doesn't know that you'll be using 2 things to map into 1. That's pretty much the reason why I never implemented this, you can't test your mappings at that point. |
Thanks for the info. I am doing this in this way: CreateMap<Things1, Thingamajigger>() Thingamajigger trouble = Mapper.Map(thing1); trouble = Mapper.Map(thing2, trouble); I may have juxtaposed the last 2 since I'm not looking at any code or documentation right now. This seems to be working. Is this best practice for this? Thank you, Phil Vuollet From: Jimmy Bogardmailto:notifications@github.com You can do this, but configuration validation won't work. It doesn't know that you'll be using 2 things to map into 1. That's pretty much the reason why I never implemented this, you can't test your mappings at that point. Reply to this email directly or view it on GitHub: |
What I usually do is create a composite object on the source side first, On Mon, Sep 23, 2013 at 9:54 AM, philn5d notifications@github.com wrote:
|
This is a little bit of an odd case where we are populating something like a view model (but a flat one) since the consumer does not work well with collections as properties. So we are mapping from 2 source services into one flat view model in an adapter/controller service for the presentation layer. In the previous example, Thingamajigger is a flattened version of Thing1 and Thing2 that exposes all properties of both in one class. Phil Vuollet From: Jimmy Bogardmailto:notifications@github.com What I usually do is create a composite object on the source side first, On Mon, Sep 23, 2013 at 9:54 AM, philn5d notifications@github.com wrote:
Reply to this email directly or view it on GitHub: |
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. |
Looking to map two+ objects into one object.
loose example:
class Person
{
public string Name { get; set; }
public string Age { get; set; }
}
class ClassRoom
{
public int RoomNumber { get; set; }
}
class PersonClassViewModel
{
public string Name { get; set; }
public string Age { get; set; }
public int RoomNumber { get; set; }
}
.
.
.
var vm = Mapper.Map(person, classRoom);
.
.
.
The text was updated successfully, but these errors were encountered: