Exemplo n.º 1
0
        /// <summary>
        /// 分页查询表(返回List)
        /// </summary>
        /// <param name="scopeList">范围查找的集合</param>
        /// <returns></returns>
        public List <T> SelectList(ScopeList scopeList)
        {
            if (scopeList.HasPage)
            {
                if (!scopeList.HasSort)
                {
                    foreach (EntityPropertyInfo pInfo in CurEntityInfo.PrimaryProperty)
                    {
                        scopeList.OrderBy.Add(pInfo.PropertyName, SortType.ASC);
                    }
                }
            }

            if (scopeList.HasInner)
            {
                return(_cdal.SelectList <T>(scopeList));
            }

            ParamList list = null;

            list = new ParamList();
            string sql = null;

            using (BatchAction ba = Oper.StarBatchAction())
            {
                if (!scopeList.HasPage)//判断是否分页查询
                {
                    sql = GetSelectContant(list, scopeList, GetSelectParams(scopeList)).GetSql(scopeList.UseCache);
                }
                else
                {
                    sql = GetSelectPageContant(list, scopeList);
                }

                List <T> retlist = null;

                Dictionary <string, bool> cacheTables = null;
                if (scopeList.UseCache)
                {
                    cacheTables = _oper.DBInfo.QueryCache.CreateMap(CurEntityInfo.TableName);
                }
                retlist = QueryList(sql, list, CommandType.Text, cacheTables);
                DataAccessCommon.FillEntityChidList(retlist, scopeList);
                return(retlist);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 查询表
        /// </summary>
        /// <param name="scopeList">范围查找的集合</param>
        /// <returns></returns>
        public DataSet Select(ScopeList scopeList)
        {
            if (scopeList.HasInner)
            {
                if (scopeList.OrderBy.Count <= 0 && scopeList.HasPage)
                {
                    foreach (EntityPropertyInfo pInfo in CurEntityInfo.PrimaryProperty)
                    {
                        scopeList.OrderBy.Add(pInfo.PropertyName, SortType.ASC);
                    }
                }
                return(_cdal.SelectDataSet <T>(scopeList));
            }

            ParamList list = null;

            list = new ParamList();

            string      sql     = null;
            PageContent objPage = scopeList.PageContent;

            using (BatchAction ba = Oper.StarBatchAction())
            {
                if (objPage == null)//判断是否分页查询
                {
                    sql = GetSelectContant(list, scopeList, GetSelectParams(scopeList)).GetSql(scopeList.UseCache);
                }
                else
                {
                    sql = GetSelectPageContant(list, scopeList);
                }


                DataSet ds = null;
                Dictionary <string, bool> cacheTables = null;
                if (scopeList.UseCache)
                {
                    cacheTables = _oper.DBInfo.QueryCache.CreateMap(CurEntityInfo.TableName);
                }
                ds = _oper.QueryDataSet(sql, list, CommandType.Text, cacheTables);

                return(ds);
            }
        }