Hello all.
This works:
EntityChild child = new EntityChild (new Guid (stringKey));
((EntityParent)parent).ChildCollection.Add (child) ; // Add to databound collection
unitOfWork.AddForSave(child) ;
...
AccessAdapter adapter = new AccessAdapter();
unitOfWork.Commit(adapter, true);
...
(Oops! That entity was a mistake... so....)
EntityChild child = ((EntityParent)parent).ChildCollection [grdChildren.ActiveRow.Index] as EntityChild;
grdChildren.DeleteSelectedRows(false) ; // Disappears from grid
unitOfWork.AddForDelete(child) ;
...
AccessAdapter adapter = new AccessAdapter();
unitOfWork.Commit(adapter, true);
No problem with that. However, this DOESN'T work...
EntityChild child = new EntityChild (new Guid (stringKey));
((EntityParent)parent).ChildCollection.Add (child) ; // Add to databound collection
unitOfWork.AddForSave(child) ;
...
(Oops! That entity was a mistake... so....)
EntityChild child = ((EntityParent)parent).ChildCollection [grdChildren.ActiveRow.Index] as EntityChild;
grdChildren.DeleteSelectedRows(false) ; // Disappears from grid
unitOfWork.AddForDelete(child) ;
...
AccessAdapter adapter = new AccessAdapter();
unitOfWork.Commit(adapter, true);
The only difference, as you can see, is that in the second code snippet, the UnitOfWork is not committed between the AddForSave(child) and the AddForDelete(child) calls.
As it turns on, in the second snippet, the EntityChild is added to the collection - even if I explicitly remove the child from the parentCollection.
In other words, once I use AddToSave(entity), there doesn't seem to be a way to undo it before the commit. No matter what I do, it WILL be saved on the next UnitOfWork.Commit call (even if its removed from the collection).
Once saved to the collection, THEN I can go back and delete it in the next UnitOfWork.Commit call.
Is this by design?
Thanks.
Jeff