This is a question about best practice for performance with Adapter when serializing dirty object graphs that's best illustrated by the usual Customer ... Order ... OrderDetail stuff.
Say I'm creating a new Order, with a few Order Details, like so:
var cust = FetchCustomer();
var order = new OrderEntity();
order.Customer = cust;
order.DateCreated = DateTime.Now;
order.OrderDetails.Add(CreateOrderDetail(...));
order.OrderDetails.Add(CreateOrderDetail(...));
order.OrderDetails.Add(CreateOrderDetail(...));
You get the idea.
I then want to save my new order via my WebService.SaveOrder(OrderEntity order) method. But when this is serialized into xml it's not just the Order and Order Details entities which are serialized, but the entire Customer entity as well. Now it seems to me that the only necessary bit of data to save the new order is the OrderEntity.CustomerId property, all the Customer data is unchanged and so it's pointless to serialize this also. Because even if we need the Customer entity in the SaveOrder(order) implementation Service-side, in most setups (where the client must communicate over the internet with the app server, but the db server is on the same LAN as the app server) it's more efficient to simply fetch it from the db than to require the client to serialize it back to the web service.
So my question is, is there a way to strip off unnecessary, clean data when serializing dirty entities back to the service? I'm aware that when creating order one could simply do order.CustomerId = customer.Id instead of order.Customer = customer, but that imposes restrictions on UI Developers that don't always get obeyed and it restricts possibilities data binding wise.