This topic applies to .NET version only
We will use a separate module to maintain a database connection and perform db4o operations: Db4o Manager.
The following function will add several Pilot objects to the database:
1public static void FillUpDB() 2
{ 3
Pilot pilot = new Pilot("Michael Schumacher", 100); 4
Db().Set(pilot); 5
pilot = new Pilot("David Barichello", 95); 6
Db().Set(pilot); 7
pilot = new Pilot("Kimi Raikkonen", 100); 8
Db().Set(pilot); 9
}
1Public Shared Sub FillUpDB() 2
Dim pilot As Pilot = New Pilot("Michael Schumacher", 100) 3
Db.Set(pilot) 4
pilot = New Pilot("David Barichello", 95) 5
Db.Set(pilot) 6
pilot = New Pilot("Kimi Raikkonen", 100) 7
Db.Set(pilot) 8
End Sub
Report's data source can accept a single object (Textbox control) or a list of objects (Table, List, Chart etc.). In this example we use a table, so a list of objects is needed:
1public static IList<Pilot> GetAllPilots() 2
{ 3
IList<Pilot> result = Db().Query<Pilot>(typeof(Pilot)); 4
return result; 5
}
1Public Shared Function GetAllPilots() As IList 2
Dim result As IList = Db.Query(GetType(Pilot)) 3
Return result 4
End Function
This function will return a list of pilot object IDs. Please, note, that the actual objects will be instantiated only as they are being retrieved from the list, which means that db4o connection should be kept open while the report is being created.