Delete behavior XData/Aurelius on child entities (relationships)

Hello Support,

I want to use XData to create a Rest/API that can be consumed by a .Net Core client.
And I want to use Aurelius to support my CRUD operations.
But, it is very important that I can handle a complete object-graph (entity with several child entity relationships) in one persist call (as a transaction).

My plan is to create all required entities, there relationships and set the correct persistent settings like cascading. On a GET call the complete entity, with all related entities are returned (json) and can be changed by the .Net Core client.

My question relates to the behavior of the persist call.
On the persist-call my service will deserialize the changed (complete) entity so Aurelius has all the information to flush the changes. This can result in sequence of creates, updates and deletes, because of the related child entities. Note, that child entities can be a reference or an embedded entity.

Reading the Aurelius documentation I belief this can work for Insert and Update, but I’m wondering how Aurelius will handle the deletion of relationships, because, the json information will not hold any state.

Example:
A Team-Entity has a list of Employees references and on persist some employees are added and some are deleted. Within that one persist call, how does Aurelius know which employee are removed from the team. The only solution I can think of is to reflect the current database records against the Team.Employees list and delete the difference.

Can you explain if this can work.
Thanks for you time.

Kind regards
Peter

Hi Peter, welcome back to our Support Center!

Yes, it will work as you expect. As you said, this is not trivial, and the more complex the object tree, the more you need to know exactly what you are doing and how to properly map your entities, including the cascades. But it works great.

But, of course, you should always test it yourself, create a proof-of-concept application and see if it works for your specific use case.

Also note that your entities need to have automatically assigned identifiers (identity, sequence, guid), the cascades won't work for manually assigned ids because then Aurelius can't tell if it should INSERT or UPDATE a record, since the id is already pre-assigned for both operations.

That's what it does.