Pregunta

I'm self hosting my WCF services using Castle windsor on windows service. Before this I was hosting them on IIS and I was registering my Repository objects (am following repository pattern with EF 5.0 as ORM) as PerWebRequest. It was working while hosting on IIS because I was able to add below line in Web.Config file -

  <system.webServer>
  <modules>
     <add name="PerRequestLifestyle" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.Windsor" />
  </modules>

but now that am self hosting. I cannot add the above module. I assume that its the recommended approach to use PerWebRequest for Repositories in WCF service otherwise it might create issues with contexts and transactions. So is there any other lifestyle which is similar to PerWebRequest that I can use while doing self hosting ? Or Please advise if my assumption is wrong?

Thanks in advance

Sai

Update

I tested with Repositories being registered to the container as Transient lifetstyle and it fails for Inserts or Updates. because everytime it requests object from container it returns a new object, so basically am loosing my DbContext object. Has anyone faced similar problem as mine?

¿Fue útil?

Solución

have you looked at built in WCF Facility lifestyles?

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top