LlblGen version 5.11, Firebird 5
My model is a ParticipantEntity 1:n relation to ChildEntity
I have the following code:
Dim NewP = New ParticipantEntity
NewP.LastName = "Smith"
NewP.Child.Add(New ChildEntity With {.Name = "One"})
NewP.Child.Add(New ChildEntity With {.Name = "Two"})
NewP.Child.Add(New ChildEntity With {.Name = "Three"})
NewP.Child.Add(New ChildEntity With {.Name = "Four"})
NewP.Save(True)
Dim NewID = NewP.Id
Debug.Print("New record = " & NewID & ":" & NewP.Child.Count.ToString)
Dim RereadFirst = New ParticipantEntity(NewID)
RereadFirst.Child.RemovedEntitiesTracker = New ChildCollection
Dim ChildTwo = RereadFirst.Child.Where(Function(x) x.Name = "Two").FirstOrDefault
RereadFirst.Child.Remove(ChildTwo)
'Here, Child.count = 3
Dim uow As New UnitOfWork
uow.AddForSave(RereadFirst, True)
If RereadFirst.Child.RemovedEntitiesTracker.Count > 0 Then uow.AddDeleteMultiCall(RereadFirst.Child.RemovedEntitiesTracker, Nothing)
uow.Commit(New Codeimation.CCMIS.ORM.Firebird.HelperClasses.Transaction(IsolationLevel.ReadCommitted, "UOW"), True)
'Here, RereadFirst.Child.Count is still 3
Dim RereadSecond = New ParticipantEntity(NewID)
'Here, RereadSecond.Child.Count = 0, and the entire Child table is empty
After that Commit, ALL the record in the Child table have been deleted.
What am I doing wrong?