官方文档说:
If ActiveRecord is running in a ASP.Net application, you must add this attribute with the value true
很自然地,我打开它并立即注意到那些使用 ActiveRecord 访问数据库的后台线程(使用 Quartz.net)崩溃了,因为它们在没有 HttpContext 时尝试访问 HttpContext。
显然官方的“解释”缺少解释部门!因此,考虑到我上面提到的几点,isWeb 的用途是什么以及为什么我应该打开它?
最佳答案
isWeb="true"
只是 threadinfotype="CaSTLe.ActiveRecord.Framework.Scopes.WebThreadScopeInfo, CaSTLe.ActiveRecord"
WebThreadScopeInfo 仅使用 HttpContext 作为 session 范围存储。如果您的代码需要在任何 HttpContext 之外使用 ActiveRecord(例如 Quartz.Net 作业),请改用 HybridWebThreadScopeInfo
。当您定义要使用的特定 threadscopeinfo 类时,无需设置 isWeb
。
关于nhibernate - CaSTLe ActiveRecord 中的 isWeb 属性是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3737019/