Store Persons

MultiExamples.cs: StorePilotsAndTrainees
01private static void StorePilotsAndTrainees() 02 { 03 File.Delete(Db4oFileName); 04 IObjectContainer container = Database(); 05 if (container != null) 06 { 07 try 08 { 09 Pilot pilot; 10 Trainee trainee; 11 for (int i = 0; i < ObjectCount; i++) 12 { 13 pilot = new Pilot("Professional Pilot #" + i, i); 14 trainee = new Trainee("Trainee #" + i, pilot); 15 container.Set(trainee); 16 } 17 container.Commit(); 18 } 19 catch (Db4oException ex) 20 { 21 System.Console.WriteLine("Db4o Exception: " + ex.Message); 22 } 23 catch (Exception ex) 24 { 25 System.Console.WriteLine("System Exception: " + ex.Message); 26 } 27 finally 28 { 29 CloseDatabase(); 30 } 31 } 32 }
MultiExamples.vb: StorePilotsAndTrainees
01Private Shared Sub StorePilotsAndTrainees() 02 File.Delete(Db4oFileName) 03 Dim container As IObjectContainer = Database() 04 If Not container Is Nothing Then 05 Try 06 Dim pilot As Pilot 07 Dim trainee As Trainee 08 Dim i As Integer 09 For i = 0 To ObjectCount - 1 Step i + 1 10 pilot = New Pilot("Professional Pilot #" + i.ToString(), i) 11 trainee = New Trainee("Trainee #" + i.ToString(), pilot) 12 container.Set(trainee) 13 Next 14 container.Commit() 15 Catch ex As Db4oException 16 System.Console.WriteLine("Db4o Exception: " + ex.Message) 17 Catch ex As Exception 18 System.Console.WriteLine("System Exception: " + ex.Message) 19 Finally 20 CloseDatabase() 21 End Try 22 End If 23 End Sub