Store Cars

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