nhibernate - CaSTLe ActiveRecord 中的 isWeb 属性是什么

标签 nhibernate castle-activerecord

官方文档说:

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/

相关文章:

nhibernate - CaSTLe 项目 Active Record 或 Fluent NHibernate

nhibernate - 异常 "instance was not in a valid state"

c# - 如何在 ASP.NET WebForms 应用程序中处理 NHibernate session ?

Nhibernate FieldNameLookup 抛出 IndexOutOfRangeException

asp.net-mvc-3 - LINQ的* OrDefault在MVC3 + ActiveRecord中引发异常

schema - 无法使用 CaSTLe ActiveRecord 创建架构

nhibernate - 有没有办法告诉 NHibernate 从模式导出中排除特定的表?

c# - 将 MVC 1 应用程序部署到远程服务器时 Global.asax 解析器错误

nhibernate - C# 事件记录实现

c# - 哪些自动代码生成工具可用于 CaSTLe ActiveRecord 类?