Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Db4o Sessionfactory
using Db4objects.Db4o;
using System.Linq;
using Db4objects.Db4o.Linq;
using System.Web;
using System.IO;
using System;
using System.Collections.Generic;
namespace Web.Infrastructure {
public class SessionFactory
static ISession _current;
//this needs to stay static - can't have more than
//one server on the file
static IObjectServer _server;
public static ISession CreateSession()
if (_server == null)
_server = Db4oFactory.OpenServer( @"c:\temp\inventoryDb", 0);
return new Db4oSession(_server);
public static Db4oSession Current
if (_current == null)
_current = CreateSession();
return (Db4oSession) _current;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment