Hello,
We're having difficulty using serialization with the entities that are to be cloned (in memory or to a file) and then saved as new ones.
The basic scenario is as follows:
1) An entity E and its 2 child collections ColA and ColB are fetched from the database using
E's prefetch paths for ColA and ColB.
2) E is serialized (either xml or binary)
...
something is done to the serialized file
...
3) E is deserialized recursively
4) We mark E's fields as changed (except for PK)
5) We try to go through the E's relationships for ColA and ColB to mark entities in the collections as new and their fields as changed but this (since it's self-servicing) triggers database calls, which in some cases (for example when saving deserialized data to a different DB) causes problems b/c in addition to the deserialized data in the collections we also have whatever matched the PK-FK relationship in the "other" DB.
Is there a way to avoid this "lazy fetch" somehow or is there a different approach? We tried using GetMembershipCollections in order to traverse those, but this did not produce new entities.
In fact, we're not even sure, why the fetch is necessary b/c the entity state in the serialized data is "Fetched" for all members of the collections in ColA and ColB
Any input appreciated.