Showing posts with label object database. Show all posts
Showing posts with label object database. Show all posts

Sunday, June 28, 2009

db4o - an Object-Database


Versant have come up with an object-database that is very easy to use.


In some cases, performance might not be there when you need it, but when this isn't a problem the benefits easily stack up.


const string dbFile = @"C:\FearlessOnes\db\Monsters.db";

IMonster monster = new Horror("Atlach-Nacha",
"Spinner in Darkness");

// If the database doesn't exist, it will be created
using (IObjectContainer db = Db4oFactory.OpenFile(dbFile))
{
db.Store(monster);
}

Nice and easy. Linq is also supported,


using (IObjectContainer db = Db4oFactory.OpenFile(dbFile))
{
monster = (from IMonster m in db.Query(typeof(IMonster))
where m.Name == "Atlach-Nacha"
select m).Single();

monster.Mode = MonsterMode.Hungry;
db.Store(monster);
}

Just reference one DLL, or two if you want to use Linq, and you're smiling.


A great tool for developing the domain layer, even if you plan to use a relational database later. Download it here. The documentation is also very good.