c# - How to implement nhibernate session per request pattern, using Service stack's funq container as a dependency injector -


i getting session injecting session service method in global.asax as

1

protected void application_start() {       this.registercontainer();  } 

2

private void registercontainer() {     container.register<iactivityservice>(c => new  activityservice(sessionfactory.getcurrentsession())); } 

3 in service method getting session as

using (var transaction = _session.begintransaction()) {     ........................         } 

the problem when concurrent requests came service method, throwing exceptions.i came know nhibernate not supporting concurency.ho achieve using funq container?

by default servicestack's ioc registers dependencies singleton default whereas should register transient dependency instead with:

container.register<iactivityservice>(c =>      new activityservice(sessionfactory.getcurrentsession())) .reusedwithin(reusescope.none); 

also previous question shows other registration examples using nhibernate servicestack.


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -