1
Ninject의 InRequestScope
확장에 문제가 있습니다. 동일한 요청 내에서 IDocumentSession
의 새 인스턴스를 가져 오는 것 같습니다. 저는 RavenDb를 ASP.NET MVC 4 베타가 포함 된 HttpServer로 실행하고 있습니다.임베디드 HttpServer 모드에서 RavenDb IDocumentSession을 사용하는 ASP.NET MVC 4 및 Ninject InRequestScope
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
그러나 물론 내가 원하는 것은 아니다. 내가 여기서 잘못하고있는 것에 대한 제안은?
그 덕분에 많은 도움이되었습니다. – Pelle