Ninject のInRequestScope
拡張機能に問題があります。IDocumentSession
同じリクエスト内で の新しいインスタンスを取得しているようです。ASP.NET MVC 4 ベータ版を使用して、組み込みの HttpServer として RavenDb を実行しています。次のようなブートストラップ クラスがあります。
public static class ApplicationBootstrapper
{
private static IKernel _kernel;
private static readonly IDocumentStore DocumentStore = new EmbeddableDocumentStore
{
DataDirectory = @"App_Data\RavenDb",
UseEmbeddedHttpServer = true
}.Initialize();
public static void Initialize()
{
DocumentStore.Conventions.IdentityPartsSeparator = "-";
_kernel = new StandardKernel();
_kernel.Bind<IUserService>().To<UserService>();
_kernel.Bind<IDocumentStore>().ToConstant(DocumentStore);
_kernel.Bind<IDocumentSession>().ToMethod(x =>
{
var store = x.Kernel.Get<IDocumentStore>();
return store.OpenSession();
}).InRequestScope();
}
public static IKernel Kernel
{
get { return _kernel; }
}
}
スコープを に設定してみましたInSingeltonScope
。そのシナリオでは、確かに同じIDocumentSession
結果が得られますが、もちろんそれは私が望むものではありません。ここで私が間違っているかもしれないことについて何か提案はありますか?