在 IIS 中托管的 Windsor ioc、wcf 设施设置下,raven doc session 和存储的推荐生活方式是什么?
我一直看到这个错误:
Error TempPathInUse (JET_errTempPathInUse, Temp path already used by another database instance)`
这是我的设置:
public class RavenInstaller : IWindsorInstaller
{
public void Install(IWindsorContainer container, IConfigurationStore store)
{
container.Register(
Component.For<IDocumentStore>().ImplementedBy<DocumentStore>()
.DependsOn(new { connectionStringName = "RavenConnectionString" })
.OnCreate(DoInitialisation)
.LifeStyle.Singleton,
Component.For<IDocumentSession>()
.UsingFactoryMethod(GetDocumentSesssion)
.LifeStyle.Transient
);
container.Register(Component.For<IEventSeriesRepository>().ImplementedBy<EventSeriesRepository>().LifeStyle.Transient);
container.Register(Component.For<IEventInstanceRepository>().ImplementedBy<EventInstanceRepository>().LifeStyle.Transient);
container.Register(
Component.For<IProductionCompanyRepository>().ImplementedBy<ProductionCompanyRepository>().LifeStyle.
Transient);
}
static IDocumentSession GetDocumentSesssion(IKernel kernel)
{
var store = kernel.Resolve<IDocumentStore>();
return store.OpenSession();
}
public static void DoInitialisation(IKernel kernel, IDocumentStore store)
{
store.Initialize();
IndexCreation.CreateIndexes(typeof(EventSeries_ByName).Assembly, store);
}
}
最佳答案
在 Raven 论坛中也提出了关于生命周期的相同问题:
https://groups.google.com/forum/#!topic/ravendb/wUgULf3eoCg
Ayende 的回应是:
文档存储的单例, session 的 transient /Web 请求。
关于wcf - ravendb、城堡 IoC、Wcf 设施 - 文档 session 生活方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5310397/