public PagingResult <TEntity> FindPaging(ISpecification <TEntity> spec)
        {
            NHibernateSpecification <TEntity> nhSpec = (NHibernateSpecification <TEntity>)spec;

            var cq = nhSpec.GetSession().Query <TEntity>();

            if (nhSpec.CriteriaExpression != null)
            {
                cq = cq.Where(nhSpec.CriteriaExpression);
            }

            PagingResult <TEntity> result = new PagingResult <TEntity>(cq.Count());

            result.AddRange(nhSpec.Query.ToList());
            return(result);
        }
Exemplo n.º 2
0
        public virtual PagingResult <T> FindPaging <T>(ISpecification <T> spec)
        {
            MongoSpecification <T> mongoSpec = (MongoSpecification <T>)spec;
            int count = 0;

            if (mongoSpec.Take > 0)
            {
                var cq = mongoSpec.GetQuery();
                if (mongoSpec.CriteriaExpression != null)
                {
                    cq = cq.Where(mongoSpec.CriteriaExpression);
                }
                count = cq.Count();
            }
            PagingResult <T> result = new PagingResult <T>(count);

            result.AddRange(mongoSpec.Query.ToList());
            return(result);
        }
        public PagingResult <Member> GetPagingMemberList(MemberSearchFilter filter)
        {
            var session = GetSession();
            var query   = session.QueryOver <Member>();

            if (!String.IsNullOrEmpty(filter.Account))
            {
                query.And(o => o.Account.IsLike(filter.Account, MatchMode.Anywhere));
            }
            query.And(o => o.CreateTime >= filter.BeginDate && o.CreateTime <= filter.EndDate);

            var list = query
                       .OrderBy(o => o.MemberId).Desc()
                       .Skip(filter.PageIndex * filter.PageSize)
                       .Take(filter.PageSize)
                       .List();

            PagingResult <Member> result = new PagingResult <Member>(query.RowCount());

            result.AddRange(list);
            return(result);
        }