JoshLindenmuth wrote:
We are having trouble removing an entity from a collection and also having the removal of that entity be reflected in related entities. We are performing all entity removal in memory, so using DeleteEntity wouldn't help.
For example:
We have a PERSON table and a related ADDRESS table. Each person can only live at 1 address, but each ADDRESS can have multiple people. For this example, let's say we have 2 people who live at Address A, and 1 person who lives at address B. If we use the Remove() function to eliminate 1 person from the PERSON entity collection, the PERSON entity collection of the related ADDRESS entity still references both people.
What's the best way to solve this issue? Particularly when we could have many related entities, not just a single table (as our simple example above)?
If you want to remove a physical relation between 2 entity instances, in this case a Person instance and an address instance, either set the person's Address property to null, or remove the person from the address' Persons collection. In memory that is. If you want to persist this change, do a recursive save.
Removing it from the persons entity collection you fetched from the person table, doesn't do that removal, as it's just a bucket with a query result.