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
查看全文
相关阅读:
2019黑龙江省大学生程序设计竞赛 赛后总结
HZNU Training 4 for Zhejiang Provincial Collegiate Programming Contest 2019
浙江大学第十九届图森未来杯大学生程序设计竞赛
HZNU Training 2 for Zhejiang Provincial Collegiate Programming Contest 2019
whu-contest-2019(online)
HZNU Training 1 for Zhejiang Provincial Collegiate Programming Contest
华为实习日记——第十九天
华为实习日记——第十八天
华为实习日记——第十七天
华为实习日记——第十六天
原文地址:https://www.cnblogs.com/shiningrise/p/887414.html
最新文章
【数位DP】[LOJ10163]Amount of Degrees
[CF587-F]WI-FI
[USACO19OPEN]Snakes
[洛谷P3672]小清新签到题
[NOIP2019模拟赛][AT2381] Nuske vs Phantom Thnook
[NOIP2019模拟赛]HC1147 时空阵
[NOIP2019模拟赛]数数(gcd)
[NOIP2019模拟赛]序列(Sequence)
Python运算符-局部英文翻译版
Python编码规范(转)
热门文章
Python安装模块相关知识
Python-day7-集合和字典
Python-day6
Python-Day3
python-Day1
转:word2vec 中的数学原理详解
POJ 1077 Eight (BFS+康托展开)详解
hNsCrHyuGF
【转载】Why Learning to Code is So Damn Hard By Erik Trautman
HZNU 2019 Summer training 6 -CodeForces
Copyright © 2011-2022 走看看