【发布时间】:2013-08-01 19:58:02
【问题描述】:
这里有小问题。 代码如下:
using (LINKSEntitiesMaster LE = new LINKSEntitiesMaster())
{
Cache["ALLDB"] = LE;
}
internal void FilterDB(string ParentPageTitle, string ButtonName)
{
var ALLdb = (LINKSEntitiesMaster)Cache["ALLDB"];
var x = ALLdb.MainTables.Where(s => s.Language == ParentPageTitle && s.ButtonName == ButtonName).Select(w => w.AllLinks).ToList();
Links.DataSource = ALLdb;
Links.DataBind();
}
错误在主题中。 我将过滤后的数据库保存到列表中,看不到连接关闭的原因...?
我一直在搜索,但找不到答案。
【问题讨论】:
-
它在 using 块结束的第二秒释放,因此您将释放的上下文存储在缓存中。