Fishy wrote:
Hi all,
I have the following to add entities to my entitycollection within an entity:
Dim GroupStudent As New GroupStudentEntity
GroupStudent.GroupIdent = _GroupEntity.GroupIdent
GroupStudent.StudentIdent = CType(grdStudents.ActiveRow.Cells("StudentIdent").Value, Integer)
_GroupEntity.GroupStudent.Add(GroupStudent)
When I call the adapter it adds the entries just fine.
Now let's say I want to delete some of those entities within the GroupStudent collection. Could I Remove them from the collection (that wouldn't work since the adapter just would not see them, right?) Is there a boolean like DeleteMe (I couldn't find one)? The only option I could think of is to create an array or collection of the the entities I want to delete and then go one by one and delete the entities. Is there a way to delete several entities with one delete sql statement?
Thanks,
Fishy
Hi, Fishy. There is no provision within the entity collections for having the "remove" action also perform a "delete". Also, as you suggested, performing a delete in the Adapter scenario isn't possible as "delete" isn't a behavior of the entity collections; it's located on the Adapter.
Your "delete bucket" is the only solution right now. I've requested a feature for the entity collections that would track changes to the collection (e.g., Deletes, Adds, etc) and allow you to pull out a UnitOfWork when you're ready to commit the changes.
Something like this:
entityCollection.StartTracking
entityCollection.Add(entity)
entityCollection.Remove(entity2)
uow = entityCollection.GetUnitOfWork()
adapter.Save(uow)
This would remove the necessity to have to maintain delete buckets and would further give you the ability to "roll back" changes to a collection if desired.
Jeff...