Ejemplo n.º 1
0
        /// <summary>
        /// 初始化分页存储过程
        /// </summary>
        private static void InitProc(DataBaseOperate oper)
        {
            if (isCheck)
            {
                return;
            }
            string      sql     = "select * from sysobjects where [xtype]='p' and [name]='" + ProcName + "'";
            bool        hasProc = false;
            IDataReader reader  = null;

            try
            {
                reader = oper.Query(sql, null, null);
                if (reader.Read())
                {
                    hasProc = true;
                }
                reader.Close();
                if (!hasProc)
                {
                    oper.Execute(GetProcCode(), null, null);
                }
            }
            finally
            {
                oper.AutoClose();
            }
            isCheck = true;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 填充字类列表
        /// </summary>
        /// <param name="pks">ID集合</param>
        /// <param name="fatherInfo">父表对应类的信息</param>
        /// <param name="dicElement">元素</param>
        /// <param name="mappingInfo">当前父表对应属性的映射信息</param>
        private static void FillParent(object pk, EntityInfoHandle fatherInfo,
                                       EntityMappingInfo mappingInfo, string propertyName, EntityBase sender)
        {
            DBInfo          db       = fatherInfo.DBInfo;
            DataBaseOperate oper     = fatherInfo.DBInfo.DefaultOperate;
            BQLDbBase       dao      = new BQLDbBase(oper);
            ScopeList       lstScope = new ScopeList();

            sender.OnFillParent(propertyName, lstScope);
            lstScope.AddEqual(mappingInfo.TargetProperty.PropertyName, pk);
            IDataReader reader = dao.QueryReader(lstScope, fatherInfo.EntityType);

            try
            {
                //获取子表的get列表
                List <EntityPropertyInfo> lstParamNames = CacheReader.GenerateCache(reader, fatherInfo);//创建一个缓存数值列表
                while (reader.Read())
                {
                    object newObj = fatherInfo.CreateSelectProxyInstance();
                    mappingInfo.SetValue(sender, newObj);
                    CacheReader.FillObjectFromReader(reader, lstParamNames, newObj, db);
                }
                sender.OnPropertyUpdated(mappingInfo.PropertyName);
            }
            finally
            {
                reader.Close();
                oper.AutoClose();
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 结束批量操作
 /// </summary>
 private void EndBatch()
 {
     if (_oper != null)
     {
         if (_oper.DBInfo.SqlOutputer.HasOutput)
         {
             _oper.OutMessage(MessageType.OtherOper, "EndBatchAction", null, "");
         }
         _oper.CommitState = _state;
         _oper.AutoClose();
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 填充字类列表
        /// </summary>
        /// <param name="pks">ID集合</param>
        /// <param name="childHandle">子元素的信息句柄</param>
        /// <param name="mappingInfo">映射信息</param>
        /// <param name="dicElement">元素</param>
        /// <param name="propertyName">属性名</param>
        /// <param name="curObjs"></param>
        /// <param name="filter"></param>
        private static void FillChilds(Queue <object> pks, EntityInfoHandle childHandle, EntityMappingInfo mappingInfo,
                                       Dictionary <string, List <object> > dicEntity, string propertyName, Queue <object> curObjs, ScopeList filter)
        {
            DBInfo                    db            = childHandle.DBInfo;
            DataBaseOperate           oper          = childHandle.DBInfo.DefaultOperate;
            BQLDbBase                 dao           = new BQLDbBase(oper);
            Queue <object>            needCollect   = null;
            List <EntityPropertyInfo> lstParamNames = null;

            try
            {
                while (pks.Count > 0)
                {
                    needCollect = GetCurPks(pks);
                    FillChildReader(needCollect, mappingInfo, dicEntity, dao, ref lstParamNames, db, curObjs, filter);
                }
            }
            finally
            {
                oper.AutoClose();
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 填充字类列表
        /// </summary>
        /// <param name="pks">ID集合</param>
        /// <param name="childHandle">子元素的信息句柄</param>
        /// <param name="mappingInfo">映射信息</param>
        /// <param name="dicElement">元素</param>
        private static void FillChilds(object pk, EntityInfoHandle childHandle, EntityMappingInfo mappingInfo,
                                       EntityBase sender, string propertyName)
        {
            EntityInfoHandle childInfo = mappingInfo.TargetProperty.BelongInfo;
            DBInfo           db        = childInfo.DBInfo;
            DataBaseOperate  oper      = childHandle.DBInfo.DefaultOperate;
            BQLDbBase        dao       = new BQLDbBase(oper);
            ScopeList        lstScope  = new ScopeList();

            sender.OnFillChild(propertyName, lstScope);
            lstScope.AddEqual(mappingInfo.TargetProperty.PropertyName, pk);


            IDataReader reader = dao.QueryReader(lstScope, childInfo.EntityType);

            try
            {
                string fullName  = mappingInfo.TargetProperty.BelongInfo.EntityType.FullName;
                Type   childType = mappingInfo.TargetProperty.BelongInfo.EntityType;

                //获取子表的get列表
                List <EntityPropertyInfo> lstParamNames = CacheReader.GenerateCache(reader, childInfo);//创建一个缓存数值列表
                IList lst = (IList)mappingInfo.GetValue(sender);
                while (reader.Read())
                {
                    object obj = childInfo.CreateSelectProxyInstance();
                    //string fk = reader[mappingInfo.TargetProperty.ParamName].ToString();
                    CacheReader.FillObjectFromReader(reader, lstParamNames, obj, db);
                    lst.Add(obj);
                }
            }
            finally
            {
                reader.Close();
                oper.AutoClose();
            }
        }