I have 1 class that I need t map into multiple classes, for eg.
This is the source that I\'m mapping from(view model):
public class UserBM
{
publ
I have another solution. The main idea is that AutoMapper know how to flatten nested objects when you name properly properties in flattened object: adding nested object property name as a prefix. For your case Location is prefix:
public class UserBM
{
public int UserId { get; set; }
public int LocationId { get; set; }
public string LocationAddress { get; set; }
public string LocationState { get; set; }
public string LocationCountry { get; set; }
...
}
So creating familiar mapping from nested to flattened and then using ReverseMap method allows AutomMapper to understand how to unflatten nested object.
CreateMap()
.ReverseMap();
That's all!