Beispiel #1
0
 /// <summary>
 /// Adds the paging to nHibernate query.
 /// </summary>
 /// <param name="query">The query.</param>
 /// <param name="options">The options.</param>
 /// <returns>The query</returns>
 public static IQueryOver <TRoot, TSubType> AddPaging <TRoot, TSubType>(this IQueryOver <TRoot, TSubType> query, SortAndPagingOptions options)
 {
     return(query.AddPaging(options.PageNumber, options.PageSize));
 }
Beispiel #2
0
        /// <summary>
        /// Adds the sorting to nHibernate query.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="options">The options.</param>
        /// <returns>The query</returns>
        public static IQueryOver <TRoot, TSubType> AddOrder <TRoot, TSubType>(this IQueryOver <TRoot, TSubType> query, SortAndPagingOptions options)
        {
            if (options != null && !string.IsNullOrWhiteSpace(options.Column))
            {
                query.UnderlyingCriteria.AddOrder(new Order(options.Column, options.Direction == SortDirection.Ascending));
            }

            return(query);
        }
Beispiel #3
0
 /// <summary>
 /// Adds the sorting and paging to nHibernate query.
 /// </summary>
 /// <param name="query">The query.</param>
 /// <param name="options">The options.</param>
 /// <returns>The query</returns>
 public static IQueryOver <TRoot, TSubType> AddSortingAndPaging <TRoot, TSubType>(this IQueryOver <TRoot, TSubType> query, SortAndPagingOptions options)
 {
     if (options != null)
     {
         return(query.AddOrder(options).AddPaging(options));
     }
     return(query);
 }
Beispiel #4
0
        /// <summary>
        /// Adds the paging to nHibernate query.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="options">The options.</param>
        /// <returns>The query</returns>
        public static IQueryable <TRoot> AddPaging <TRoot>(this IQueryable <TRoot> query, SortAndPagingOptions options)
        {
            if (options != null)
            {
                if (options.PageNumber > 0)
                {
                    query = query.Skip(options.PageSize * (options.PageNumber - 1));
                }

                if (options.PageSize > 0)
                {
                    query = query.Take(options.PageSize);
                }
            }

            return(query);
        }
Beispiel #5
0
        /// <summary>
        /// Adds the sorting to nHibernate query.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="options">The options.</param>
        /// <returns>The query</returns>
        public static IQueryable <TRoot> AddOrder <TRoot>(this IQueryable <TRoot> query, SortAndPagingOptions options)
        {
            if (options != null && !string.IsNullOrWhiteSpace(options.Column))
            {
                return(query.OrderBy(options.Column, options.Direction));
            }

            return(query);
        }
Beispiel #6
0
        /// <summary>
        /// Adds the sorting and paging to nHibernate query.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="options">The options.</param>
        /// <returns>The query</returns>
        public static IQueryable <TRoot> AddSortingAndPaging <TRoot>(this IQueryable <TRoot> query, SortAndPagingOptions options)
        {
            if (options != null)
            {
                return(query.AddOrder(options).AddPaging(options));
            }

            return(query);
        }