Created
January 9, 2011 21:44
-
-
Save Itslet/772059 to your computer and use it in GitHub Desktop.
Db4o Sessionfactory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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