My question is in regards to how Open Access is handling identity colums with tables that have foreign references.
Say For example I have the following Persistent classes:
|Public Class Tmp
| Private Dim _id As Integer ' pk identity field auto increment
| Private Dim _name As String
| Private Dim _tmpchild As IList(OF TmpChild) = New List(OF TmpChild)()
| Private Dim _tmpjobid As Integer ' pk
| Private Dim _value As String
| Private Dim _tmp As Tmp ' inverse Tmp._tmpChild
Is it possible to create a new Tmp object and add TmpChild object to the newly created in one Transaction?
parent = New Tmp
child = New TmpChild
parent.Name = "John Joe"
parent.children.Add(child) ' internally the new parent id would be assigned then should be used in adding the child object
Catch e As Exception
This creates a foreign key error because the id does not exist when adding.
Or do we need to get the identity value returned then add the child values? This creates a problem because if the parent insert was successful and the child insert failed It requires that the parent insert now be deleted.
What's the best way to accomplish this?