In my data layer, I have a repository that can return a list of such items:
new List<Item> { new Item { Title = "Something", DetailId = 500 }, new Item { Title = "Whatever", DetailId = 501 }, }
There is another method in the repository that can return data for these elements if a part identifier is specified:
// repository.GetDetail(500) would return something like: new ItemDetail { Id = 500, Size = "Large" }
Now, in my service layer, I would like to match the above list with the following:
new List<ServiceItem> { new ServiceItem { Title = "Something", Size = "Large" }, new ServiceItem { Title = "Whatever", Size = "Medium" }, }
Please note that I need properties from both objects in the list ( Title in this case) and from detailed objects. Is there a good way to map this to AutoMapper?
I thought about creating a profile that depends on the instance of my repository, and then AutoMapper performs detailed queries, but it looks like it is mess to let AutoMapper retrieve new data?
Is there a clean way to map two objects into one?
source share