zoukankan
html css js c++ java
ActiveRecord Enabling lazy load 方案
lazy load AR 官的方案是
BeginRequest
+=
new
EventHandler(OnBeginRequest);
EndRequest
+=
new
EventHandler(OnEndRequest);
//
Initialization code omitted
}
protected
void
Application_End(
object
sender, EventArgs e)
{
}
public
void
OnBeginRequest(
object
sender, EventArgs e)
{
//
HttpContext.Current.Items.Add("nh.sessionscope", new SessionScope());
}
public
void
OnEndRequest(
object
sender, EventArgs e)
{
//
try
//
{
//
SessionScope scope = HttpContext.Current.Items["nh.sessionscope"] as SessionScope;
//
if (scope != null)
//
{
//
scope.Dispose();
//
}
//
}
//
catch (Exception ex)
//
{
//
HttpContext.Current.Trace.Warn("Error", "EndRequest: " + ex.Message, ex);
//
}
}
但我用这个办法,后来建了个PageBase.cs
using
System;
using
System.Data;
using
System.Configuration;
using
System.Web;
using
System.Web.Security;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Web.UI.WebControls.WebParts;
using
System.Web.UI.HtmlControls;
using
Castle.ActiveRecord;
namespace
Wz16.WebApp
{
public
class
PageBase : System.Web.UI.Page
{
protected
SessionScope CurSessionScope ;
protected
override
void
OnInit(EventArgs e)
{
CurSessionScope
=
new
SessionScope();
base
.OnInit(e);
}
public
override
void
Dispose()
{
try
{
if
(CurSessionScope
!=
null
)
{
CurSessionScope.Dispose();
}
}
catch
(Exception ex)
{
HttpContext.Current.Trace.Warn(
"
Error
"
,
"
EndRequest:
"
+
ex.Message, ex);
}
base
.Dispose();
}
}
}
继承自PageBase.cs的页面就都支持 AR 的 Lazy Load
我用的 asp.net2.0 为什么官方的方案会不行,有知道的人请赐教。
欢迎光临:
http://shiningrise.cnblogs.com
查看全文
相关阅读:
团队建设
风云变幻六十年 平板电脑演变史回顾
在线ide汇总
XAMPP中启动tomcat报错的解决方法
ExtJs 中 xtype 与组件类的对应表
FineReport关于Linux下字体乱码终极解决方案
SqlDataReader的关闭问题
MemberShip学习之:注册用户
索引超出范围。必须为非负值并小于集合大小。
利用SiteMapPath控件做论坛导航(也适合其它系统)
原文地址:https://www.cnblogs.com/shiningrise/p/887414.html
最新文章
博客园边栏滚动隐藏代码
移动互联网产品设计的原则
ios资源汇总
WPoMatic数据采集器 汉化版,以及BUG修改.
mvn备忘
刷新标签中的iframe,调用iframe中的函数
windows下tortoisegit图形化协同编程
PowerDesigner中通过VBS脚本修改模型信息(转)
漫谈看守所
测试一下可运行的js
热门文章
PowerDesigner 11 一些小技巧
Maven 3 入门
我对于android机的按键交互的分析
java project转为maven
怎样查看Eclipse运行java程序时用的命令(转)
标签云
代码整洁之道 垃圾编码收集
读数学之美
建议检察院服务器服务器配置 显示器,切换器 键鼠
jrockit 下载
Copyright © 2011-2022 走看看