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
查看全文
相关阅读:
eclipse项目迁移到android studio(图文最新版)
栈上分配存储器的方法 alloca 抽样
【PHP】PHP获得第一章
阿里2015回顾面试招收学历(获得成功offer)
Linux 于 shell 变数 $#,$@,$0,$1,$2 含义解释:
Codeforces 451E Devu and Flowers(容斥原理)
hdu 4964 Emmet()模拟
“度”思考
Windows Auzre 微软的云计算产品的后台操作界面
Java设计模式菜鸟系列(两)建模与观察者模式的实现
原文地址:https://www.cnblogs.com/shiningrise/p/887414.html
最新文章
mysql笔试题大餐---1、组合查询方式及having
Android设计模式(十)--生成器模式
【网络流量最大流量】poj3281Dining
【房费制】抽象
Java的λ表达(lambda)
根据要求求除数的数 与 互素和算法 (的品质因数和欧拉函数分解)
tcpdump参数及使用介绍(转)
IOS使用Jenkins持续集成
网站压力测试工具Webbench介绍
docker 真实---安装基本映像 (一)
热门文章
Block学习一门:基本使用,使用block包NSURLRequest异步请求
可失败构造器(Failable Initializers)
为iPhone6设计自适应布局(二)
为iPhone6 设计自适应布局(一)
Swift自适应布局(Adaptive Layout)教程(二)
为iPhone6设计自适应布局(一)
为iPhone 6设计自适应布局
Android 4.2蓝牙介绍
iOS 8 Auto Layout界面自动布局系列5-自身内容尺寸约束、修改约束、布局动画
Android状态栏颜色修改
Copyright © 2011-2022 走看看