There was a very interesting discussion on LosTechies regarding AutoMapper(an argument for/against 2-way mapping).
This actually caught my attention due to the problem I'm currently working through. I'm working on a shipment piece to provide information such as rates/delivery times to my users. To centralize the actual services, I have a WCF web service which persists any domain entities.
To simplify the domain model I basically have 2 classes:
public class Shipment
{
public IList<Item> Items{get;set;}
}
public class Item
{
//some primitive properties
}
I also have a corresponding set of DTOs that were created to lighten the load across the wire. The presentation piece(or pieces, whatever touches the web service), use the DTOs with no knowledge of the domain model.
My question comes here. To create a shipment, the service accepts a list of items. There is logic to creating shipments, which is all hidden behind the web service. In essence, this means that ItemDTO is passed across the wire(client -> server), shipments are created, then ShipmentDTO is passed back(server -> client). Now, ShipmentDTO has a child list of ItemDTO as well, which creates the 2-way mapping scenario.
This is more than a simple CRUD operation and I'm farely new to the Command Message pattern, so I'm curious how the community would solve this issue.
Do you pass a DTO both ways with 2-way mapping?
Sample usage(presentation layer):
List<ItemDTO> list = new List<ItemDTO>();
//add items to list
ShipmentServiceClient client = new ShipmentServiceClient();
List<ShipmentDTO> shipments = client.GetShipments(list);
//shipments are now displayed to the user
//with respective costs and other useful data