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
查看全文
相关阅读:
数据可视化
numpy知识点
机器学习之支持向量机
python中字符编码及unicode和utf-8区别
hihocoder图像算子(高斯消元)
scrapy
线性规划问题求解(单纯形法)
机器学习之隐含马尔可夫
机器学习之决策树
机器学习之逻辑回归与最大熵模型
原文地址:https://www.cnblogs.com/shiningrise/p/887414.html
最新文章
方法重载的使用与练习
对象的练习
ArrayUtil的创建和使用
创建java类并实例化类对象
面向对象的编程思想和Java中类的概念与设计
数组的常用算法二之排序算法
数组的常用算法
二维数组的练习
数组常见的异常
多维数组的使用
热门文章
约瑟夫(Josephus)问题~转
Codeforces Round #427 (Div. 2) B. The number on the board
Codeforces Round #426 (Div. 2)A B C题+赛后小结
Mutual Training for Wannafly Union #6 E
鬼知道是啥系列之——STL(lower_bound(),upper_bound() )
POJ 2828Buy Tickets(线段树的单点维护)
POJ 3468A Simple Problem with Integers(线段树区间更新)
POJ 1577Falling Leaves(二叉树的建立)
Educational Codeforces Round 25 C. Multi-judge Solving
Educational Codeforces Round 25 B. Five-In-a-Row
Copyright © 2011-2022 走看看