Skip to content

Instantly share code, notes, and snippets.

@Itslet
Created January 9, 2011 21:44
Show Gist options
  • Save Itslet/772059 to your computer and use it in GitHub Desktop.
Save Itslet/772059 to your computer and use it in GitHub Desktop.
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
{
get
{
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