MVC 创建线程内的db单例

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using LSUnion.Site.Models; namespace LSUnion.Site.WebHelper
{
using System.Runtime.Remoting.Messaging;
public class Factory
{
public static LSUnionEntities GetDbContext()
{
object db = CallContext.GetData("LSUnionEntities");
if (db==null)
{
db = new LSUnionEntities();
CallContext.SetData("LSUnionEntities",db);
}
return db as LSUnionEntities;
}
}
}
上一篇:c++:自己动手实现线程安全的c++单例类


下一篇:iOS-主线程刷新UI【+单例】