开发者

NHibernate ISession usage and thread safety

开发者 https://www.devze.com 2023-01-23 03:22 出处:网络
When I configure my ISession lifetime to be \'per HTTP request\' (InstancePerLifetimeScope in Autofac which I\'m using), NHibernate profiler tells me that my Session is being used across threads, whic

When I configure my ISession lifetime to be 'per HTTP request' (InstancePerLifetimeScope in Autofac which I'm using), NHibernate profiler tells me that my Session is being used across threads, which is most likely a bug. What is going on? I'm used to thinking that I should scope unit of work to http request but it seems that session is indeed being used across threds.

Essentially this 'ISession per HTTP request' conflicts with NHibernate pr开发者_开发知识库ofiler alerts. Where am I wrong?

UPDATE: I do have a ContainerDisposalModule in my Web.config, so the disposing works as it should


IIS (like most web servers) uses multiple threads to serve requests so this is probably not a bug in your application and you can safely ignore the warnings.

See also this question.

0

精彩评论

暂无评论...
验证码 换一张
取 消