01
using System;
02
using System.Collections.Generic;
03
using System.IO;
04
using Db4objects.Db4o;
05
using Db4objects.Db4odoc.ReportsExample.Persistent;
06
07
namespace Db4objects.Db4odoc.ReportsExample.Modules
08
...{
09
class Db4oManager
10
...{
11
public const string DbFileName = "..//..//Data//formula1.db";
12
public static IObjectContainer _db;
13
14
private Db4oManager()
15
...{
16
}
17
// end Db4oManager
18
19
public static void FillUpDB()
20
...{
21
Pilot pilot = new Pilot("Michael Schumacher", 100);
22
Db().Set(pilot);
23
pilot = new Pilot("David Barichello", 95);
24
Db().Set(pilot);
25
pilot = new Pilot("Kimi Raikkonen", 100);
26
Db().Set(pilot);
27
}
28
// end FillUpDB
29
30
public static IList<Pilot> GetAllPilots()
31
...{
32
IList<Pilot> result = Db().Query<Pilot>(typeof(Pilot));
33
return result;
34
}
35
// end GetAllPilots
36
37
public static void StoreObject(Object obj)
38
...{
39
Db().Set(obj);
40
}
41
// end StoreObject
42
43
public static IObjectContainer Db()
44
...{
45
if (_db == null)
46
...{
47
_db = Db4oFactory.OpenFile(DbFileName);
48
}
49
return _db;
50
}
51
// end Db
52
53
public static void CloseDb()
54
...{
55
if (_db != null)
56
...{
57
_db.Close();
58
}
59
}
60
// end CloseDb
61
}
62
}