arschr wrote:
Fastest way is to add the entity to a UoW to save recursively, then call ConstructSaveProcessQueues on the UoW and you have your 2 queues with entities which are dirty or WILL get dirty because a dependent entity is scheduled to be saved.
I've not worked with uow. I'll look at it. Does it seem to you that it provides the features I'm asking for?
You actually can better use the class ObjectGraphUtils, which is in the ormsupportclasses as well, and then call one of the DetermineActionQueues routines. (that class is used to determine the queues for a graph anyway
) These then will produce the queues for you, and you just have to traverse these to get all dirty or to be dirty entities in your graph.
Though if this is for rolling back changes in a form if the user clicks cancel: do this per control/data that's bound: first call SaveFields() on all entities involved, then when cancel is clicked, call RollbackFields on those entities.
No, as it's not solvable. It's effectively 'graph' versioning, which is very very complex. It's also complicated because it can be that an entity effects more than 1 other related entities (when an entity has multiple m:1 relations with different entities for example).
I don't think graph versioning is what is needed, tree versioning is. Is that then solvable?
It's not a tree, unfortunately, it's a directed graph.
If I have a order or some other parent type entity, when I ask if it or it's children are dirty or if I ask to save it and it's children. It's not "normal" in the real world to want or expect that changes to it's parents would be included/saved. If I use an order to change the address of the customer it belongs to, I should save the customer and it's children not the order and it's parents and children. I know that what is the parent and what is the child is not always clear.
The IsDirty flag is to signal that THAT particular entity is changed and should be persisted. The thing is: as soon as you change 1 field in an entity in a graph, the whole graph gets 'dirty' by your definition, which is IMHO not the case: only that entity is dirty.
By simplifying the model to tree situations, I think you would meet 90% to 99% of the real world requirements while providing a feature that would save the users of llblgen a lot of work.
That's not possible, it's not a tree. I once started implementing graph versioning, but hit a wall while doing it, as it looks simple at first, but then the complexity explodes once you encounter what can happen.
I've thought about having versioning in a context. For example, you add an entity or a set of entities to a context and use that context to version the entities which are inside it. It effectively pushes the state of all the entities involved.
The problems began when I realized it didn't solve the problems I ran into when I started with versioning graphs before: what if you add an order to a customer's order collection, add entities to that etc. ? What if you save in between? This thus means that all entities related to a given entity in the context are also part of the state of the whole graph: if you dereference an entity, and roll back the state, the entity should again be referenced.
This is in a way solvable, but not easily. I chose to leave it for now, as often it's solveable as well by the application programmer who just wants to have versioning over a bunch of entities in a grid: traverse them prior to binding: call SaveFields(name) on all of them, and when cancel is clicked, traverse them again and call RollbackFields(name).