- using System;
- using System.Collections.Generic;
- using System.Data.Entity;
- using System.Linq;
- using System.Runtime.Remoting.Contexts;
- using System.Runtime.Remoting.Messaging;
- using System.Text;
- using Dulei.Model;
- namespace Dulei.DAL
- {
- public class EFDbcontextFactory
- {
- public static DbContext GetcurrentDbcontext()
- {
- DbContext db = (DbContext) CallContext.GetData("Dbcontext");
- if (db==null)
- {
- db = new DataModelContainer();
- CallContext.SetData("Dbcontext",db);
- }
- //也可以使用HttpContext是一样的
- return db;
- }
- }
- }