Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="searchExpression"></param>
        /// <param name="searchOrders"></param>
        /// <param name="func"></param>
        protected override void GetDataCount(ISearchExpression searchExpression, IList <ISearchOrder> searchOrders,
                                             Action <object> func)
        {
            List <T> dataSource = new List <T>();
            int      count;

            using (var rep = new Repository(this.RepositoryCfgName))
            //using (var tx = rep.BeginTransaction(System.Data.IsolationLevel.ReadCommitted))
            {
                rep.BeginTransaction();
                ActionableList <object> actionList = new ActionableList <object>(dataSource, func);

                GetData(searchExpression, searchOrders, rep.Session, actionList);

                // 当不是第一页的时候,不能通过返回条数当作总条数
                if (this.EnablePage && this.FirstResult == 0 && dataSource.Count < this.MaxResult)
                {
                    count = dataSource.Count;
                }
                else
                {
                    count = GetCount(searchExpression, rep.Session);
                }

                rep.CommitTransaction();
            }

            base.Count = count;

            base.Result = dataSource;
        }
Exemplo n.º 2
0
        private void GetData(ISearchExpression searchExpression, IList <ISearchOrder> searchOrders,
                             NHibernate.ISession session, ActionableList <object> actionList)
        {
            NHibernate.ICriteria criteria = CreateCriteria(session, searchExpression, searchOrders, ref m_hasCollection);

            OnCriteriaCreated(criteria);

            criteria.List(actionList);
        }