This question is locked. New answers and comments are not allowed.
Okay.
I am using OpenAccess forward mapping and have the following scenario.
ObjectA
ObjectB
There is a one to many relationship between ObjectA and ObjectB.
I can create ObjectA and an instance of ObjectB with no problem. I then add ObjectB to the collection on Object which is is basically the 1:m relationship and this is fine also. My issue comes up when I delete ObjectA. Currently when I delete ObjectA it also deletes ObjectB as well. What I need is for the mapping to be deleted but to not actually delete ObjectB.
I'm currently doing that this way, but I feel there may be a better implementation. Any thoughts?
Thank you.
I am using OpenAccess forward mapping and have the following scenario.
ObjectA
ObjectB
There is a one to many relationship between ObjectA and ObjectB.
I can create ObjectA and an instance of ObjectB with no problem. I then add ObjectB to the collection on Object which is is basically the 1:m relationship and this is fine also. My issue comes up when I delete ObjectA. Currently when I delete ObjectA it also deletes ObjectB as well. What I need is for the mapping to be deleted but to not actually delete ObjectB.
I'm currently doing that this way, but I feel there may be a better implementation. Any thoughts?
Thank you.
' grab the scopeDim scope As IObjectScope = ScopeProvider.ObjectScopescope.Transaction.Begin()' fetch objectA from the scope that is to be deletedDim si As ObjectA = ObjectA.GetItem(Of ObjectA)(scope, Id)' we need to break the association of any ObjectB to the ObjectA before we actually delete the ObjectADo While si.ObjectBCollection.Count > 0 si.ObjectBCollection.Remove(si.ObjectBCollection(0))Loop' physically delete ObjectAscope.Remove(si)scope.Transaction.Commit()