Class α Public Property Identity As Integer 'αの主キー Public Property MemberOfAlpha As String 'αのメンバー Public Property Children As List(Of β) End Class Class β Public Property Identity As Integer 'βの主キー Public Property MemberOfBeta As String 'βのメンバー Public Property Children As List(Of γ) End Class Class γ Public Property Identity As Integer 'γの主キー Public Property MemberOfGamma As String 'γのメンバー End Class
connection.Execute(queryInsertAlpha, listOfAlpha) connection.Execute(queryInsertBeta, listOfAlpha.SelectMany(Function(a) a.Children.Select( Function(b) New With { Key .aID = a.Identity, Key .bID = b.Identity, b.MemberOfBeta })) ) connection.Execute(queryInsertGamma, listOfAlpha.SelectMany(Function(a) a.Children.SelectMany(Function(b) b.Children.Select( Function(g) New With { Key .aID = a.Identity, Key .bID = b.Identity, Key .gID = g.Identity, g.MemberOfGamma }))) )