示例#1
0
        //public UnitOfWorkBase(ContextCache contextCache)
        //{
        //    this.contextCache = contextCache;
        //}

        //public UnitOfWorkBase(DbContext dbcontext)
        //{
        //    dbContext = dbcontext;
        //    ticks = DateTime.Now.Ticks;
        //}

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="contextCache"></param>
        /// <param name="dbcontext"></param>
        public UnitOfWorkBase(ContextCache contextCache, DBContextBase dbcontext)
        {
            dbContext         = dbcontext;
            this.contextCache = contextCache;
            ticks             = DateTime.Now.Ticks;
            // 记录sql
            dbContext.Database.Log = (sql) =>
            {
                if (string.IsNullOrEmpty(sql) == false)
                {
                    SqlLog.AppendLine(sql);
                    if (DebugSql)
                    {
                        Debug.WriteLine(sql);
                    }
                }
            };
        }