(Day 4 learning experience)
I have a datagrid (Infragistics) with parent child realtionship.
I am using adapter not self service.
This is bound to an entity collection 'entityCollection1' as such in the form load event handler
PrefetchPath2 CommsPath = new PrefetchPath2((int)EntityType.CasesEntity);
CommsPath.Add(CasesEntity.PrefetchPathCommunicationsLog);
adapter.FetchEntityCollection(entityCollection1, null, CommsPath);
After I have made changes (updates and inserts) I use
adapter.SaveEntityCollection(entityCollection1, true, true); to persist the changes back to the database. Works ok!
I know one can use adapter.DeleteEntityCollection(entityCollection1) to delete all the records in the entity collection (did not know this until I tried it and got a not nice surprise). I thought it have deleted just the deleted rows.
I see that one needs to capture the deleted rows by capturing these into another entity collection. I have looked at the help but it is not clear or least it does not match what I am trying to achieve.
I have tried add this to my form class
private EntityCollection DeletedData = new EntityCollection();
and modified the form load event handler to
PrefetchPath2 CommsPath = new PrefetchPath2((int)EntityType.CasesEntity);
CommsPath.Add(CasesEntity.PrefetchPathCommunicationsLog);
**entityCollection1.RemovedEntitiesTracker = DeletedData;**
adapter.FetchEntityCollection(entityCollection1, null, CommsPath);
In the my save button event handler I call
adapter.SaveEntityCollection(entityCollection1, true, true);
to persist updates and inserts but I am not sure how one handles the deletes.
The help talks about unitsofwork and so forth.
All I want to do is delete the rows deleted parents and children or just deleted children back to the database.
How do I use the deleted entity collection to delete the rows deleted in my grid?
Am I on the right track or right off beam?