My application needs to display a table of customer data, including data about the customer and about his most recent order from a given warehouse. The customer domain object contains a GetLatestOrder(warehouseId) method.
I have a CustomerView viewmodel and want to be able to populate it with some fields from the customer object, and a few fields from the latest order object. Can I do this using Automapper?
In the end, I took the easy approach, couldn't find another way:
In Application_start:
In the controller method:
Try this,
In
Global.asax.cs
[Application_Start
],public static void AppInitialize()
And in your code call the mapper like below,
I am presumed that you classes looks like below,
Also refer this post.
Yes, you can:
Each mapping will populate the properties it is configured to and leave the rest.