Я новичок в RavenDb. Я построил фабрику сеансов RavenDB, как и код ниже. Идея очень сильно зависит от того, как мы строим NHibernateSessionHelpers. Надеюсь, что это должно хорошо работать в производстве. Есть ли предложения по улучшению этого от людей, которые являются экспертами в RavenDB?RavenDB- Building Session Factory, singleton DocumentStore
public class MXRavenDbSessionHelper
{
//---All new lazy singleton that's thread safe.---
private static Lazy<IDocumentStore> _lazyDocStore = new Lazy<IDocumentStore>(() => InitializeSessionFactory());
private MXRavenDbSessionHelper() { }
private static IDocumentStore SessionFactory
{
get
{
return _lazyDocStore.Value;
}
}
public static IDocumentSession OpenSession()
{
return SessionFactory.OpenSession();
}
private static IDocumentStore InitializeSessionFactory()
{
var _docStore = new DocumentStore { ConnectionStringName = "RavenDBConnString", DefaultDatabase = "MXMunky" }; //One more way is this : _store = new DocumentStore { Url = "http://localhost:7000" };
_docStore.Initialize();
_docStore.Conventions.IdentityPartsSeparator = "-";
IndexCreation.CreateIndexes(typeof(Location).Assembly, _docStore);
return _docStore;
}
}
oh ya. _docStore здесь устарел, моя ошибка. Я обновил код. Статья Джона Скита о одиночных играх абсолютно велика. Спасибо Мэтту –