This topic applies to .NET version only
Steps to build Mono distribution.
As a native .NET database db4o can be used on Mono, open source development platform based on the .NET framework. db4o Mono support is a community project, hosted at db4o Project Spaces.
db4o can be built from db4o sources which are available at db4o svn.
In order to build db4o library you can use:
gnu make: Makefile is provided in db4o.net/Db4objects.Db4o folder
nant task: an example default.build (using csc) is provided in db4o.net folder.
Please, bear in mind that db4o for Mono
is a community supported project and its correct functionality is not
guaranteed. If you encounter compile errors during db4o build you can log the problem at Mono bugzilla. You are also welcome to
participate in db4o on Mono project development and improvement.
Once you've done the build you can test db4o functionality on Mono with a simple example:
01using System; 02
using System.IO; 03
04
using Db4objects.Db4o; 05
using Db4objects.Db4o.Query; 06
07
08
namespace Db4objects.Db4odoc.MonoTest 09
{ 10
11
public class MonoTest 12
{ 13
private const string Db4oFileName = "test.db4o"; 14
15
public static void Main(string[] args) 16
{ 17
File.Delete(Db4oFileName); 18
IObjectContainer db = Db4oFactory.OpenFile(Db4oFileName); 19
try 20
{ 21
Pilot pilot1 = new Pilot("Michael Schumacher", 100); 22
db.Set(pilot1); 23
Console.WriteLine("Stored {0}", pilot1); 24
} 25
finally 26
{ 27
db.Close(); 28
} 29
db = Db4oFactory.OpenFile(Db4oFileName); 30
try 31
{ 32
IObjectSet result = db.Get(typeof(Pilot)); 33
ListResult(result); 34
} 35
finally 36
{ 37
db.Close(); 38
} 39
} 40
// end Main 41
42
private static void ListResult(IObjectSet result) 43
{ 44
System.Console.WriteLine(result.Count); 45
for (int i = 0; i < result.Count; i++) 46
{ 47
System.Console.WriteLine(result[i]); 48
} 49
} 50
// end ListResult 51
52
53
class Pilot 54
{ 55
private string _name; 56
private int _points; 57
58
public Pilot(string name, int points) 59
{ 60
_name = name; 61
_points = points; 62
} 63
64
public string Name 65
{ 66
get 67
{ 68
return _name; 69
} 70
set 71
{ 72
_name = value; 73
} 74
} 75
76
public int Points 77
{ 78
get 79
{ 80
return _points; 81
} 82
} 83
84
public override string ToString() 85
{ 86
return string.Format("{0}/{1}", _name, _points); 87
} 88
} 89
90
} 91
}
In order to compile and run the example you can use the following command:
mcs MonoTest.cs
/r:Db4objects.Db4o.dll
mono MonoTest.exe
(It is assumed that Db4objects.Db4o.dll is in the same directory as the example file).