public static IDAL.IDBSession CreateDbSession() { IDAL.IDBSession DbSession = (IDAL.IDBSession)CallContext.GetData("dbSession"); if (DbSession == null) { DbSession = new DALFactory.DBSession(); CallContext.SetData("dbSession", DbSession); } return(DbSession); }
public static IDAL.IDBSession CreateDBSession() { IDAL.IDBSession dBSession = (IDAL.IDBSession)CallContext.GetData("dbSession"); if (dBSession == null) { dBSession = new DBSession(); CallContext.SetData("dbSession", dBSession); } return(dBSession); }
public static IDAL.IDBSession CreateDBSession() { IDAL.IDBSession DBSession = (IDAL.IDBSession)CallContext.GetData("DBSession"); if (DBSession == null) { DBSession = new DBSession(); CallContext.SetData("DBSession", DBSession); } return(DBSession); }
/// <summary> /// 此方法的作用: 提高效率,在线程中 共用一个 DBSession 对象! /// </summary> /// <returns></returns> public IDAL.IDBSession GetDBSession() { //从当前线程中 获取 DBContext 数据仓储 对象 IDAL.IDBSession dbSesion = CallContext.GetData(typeof(DBSessionFactory).Name) as DBSession; if (dbSesion == null) { dbSesion = new DBSession(); CallContext.SetData(typeof(DBSessionFactory).Name, dbSesion); } return(dbSesion); }
public static IDAL.IDBSession CreateDBSession() { IDAL.IDBSession DbSession = (IDAL.IDBSession)CallContext.GetData("dbSession"); //判断一下EF的对象是否已经闯将 这个请求 如果已经创建了 就直接使用 //这个DBsessionFactory还木有用到 //这个和DbContext是一个道理 //服务端校验。 数据映射 if (DbSession == null) { DbSession = new DALFactory.DBSession(); CallContext.SetData("dbSession", DbSession); } return(DbSession); }
/// <summary> /// 创建线程内唯一的DBSession /// </summary> /// <returns></returns> public static IDAL.IDBSession CreateDbSession() { //1 获取当前线程中的EF上下文对象 IDAL.IDBSession DbSession = CallContext.GetData(typeof(DBSessionFactory).Name) as IDAL.IDBSession; //判断当前线程中 是否包含EF上下文对象,若不存在则创建 if (DbSession == null) { DbSession = new DBSession(); CallContext.SetData(typeof(DBSessionFactory).Name, DbSession); } return(DbSession); }