为什么当我使用这个单例时,负载检索总是空的?
public class DataLayer
{
private EmbeddableDocumentStore d;
private static object lockerSingleton = new object();
private static DataLayer _current;
public static DataLayer RavenDB
{
get
{
lock (lockerSingleton)
{
if (_current == null)
_current = new DataLayer();
}
return _current;
}
}
public DataLayer()
{
d = new EmbeddableDocumentStore() { DataDirectory = "csv" };
d.Initialize();
}
public void store<T>(T obj)
{
using (var session = d.OpenSession())
{
session.Store(obj);
session.SaveChanges();
}
}
public T retrieve<T>(object ID)
{
using (var session = d.OpenSession())
{
return session.Load<T>(ID.ToString());
}
}
}