I'm looking for a way to control which related entities get included when I'm serializing an entity. This has been discussed before at www.llblgen.com/tinyforum/Messages.aspx?ThreadID=13277 but I'm wondering if anything has changed since then, or if someone has come up with an approach. I am using LLBLGen 3.1.
The scenario: using WCF, I send a customer and all its orders to the client. On the client I make a change to one order and then send it back to the server. This causes the order, the customer, and all the other orders for the customer to be serialized and sent back, even though they have not changed.
It would be nice if there were a method I could override to determine whether each relation should be serialized. It's pretty easy to figure out whether related entities should get shipped back, based on whether they're new/modified or based on other business rules.
The only solution I've found is to hide all the relationships that I don't want getting traversed during serialization. For example, remove the "Orders" relationship from the Customer, so that when I serialize an Order the Customer will be serialized along with it, but at least all the other orders won't be included.
The approach discussed in the previous thread (set the FK value on the order rather than assigning the entity) only works for new child entities; it doesn't hold up if you're dealing with entities that have been fetched on the server and serialized to the client with the related entities already fetched.