mirror of
				https://github.com/nsnail/FreeSql.git
				synced 2025-11-04 17:20:49 +08:00 
			
		
		
		
	@@ -319,6 +319,13 @@ namespace FreeSql.Internal.CommonProvider
 | 
			
		||||
            return this.Limit(pageSize) as TSelect;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public TSelect Page(BasePagingInfo pagingInfo)
 | 
			
		||||
        {
 | 
			
		||||
            pagingInfo.Count = this.Count();
 | 
			
		||||
            this.Skip(Math.Max(0, pagingInfo.PageNumber - 1) * pagingInfo.PageSize);
 | 
			
		||||
            return this.Limit(pagingInfo.PageSize) as TSelect;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public TSelect Skip(int offset)
 | 
			
		||||
        {
 | 
			
		||||
            _skip = offset;
 | 
			
		||||
 
 | 
			
		||||
@@ -201,6 +201,14 @@ namespace FreeSql.Internal.CommonProvider
 | 
			
		||||
            return this;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public ISelectGrouping<TKey, TValue> Page(BasePagingInfo pagingInfo)
 | 
			
		||||
        {
 | 
			
		||||
            pagingInfo.Count = this.Count();
 | 
			
		||||
            _groupBySkip = Math.Max(0, pagingInfo.PageNumber - 1) * pagingInfo.PageSize;
 | 
			
		||||
            _groupByLimit = pagingInfo.PageSize;
 | 
			
		||||
            return this;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public long Count() => _select._cancel?.Invoke() == true ? 0 : long.TryParse(string.Concat(_orm.Ado.ExecuteScalar(_select._connection, _select._transaction, CommandType.Text, $"select count(1) from ({this.ToSql($"1{_comonExp._common.FieldAsAlias("as1")}")}) fta", _select._commandTimeout, _select._params.ToArray())), out var trylng) ? trylng : default(long);
 | 
			
		||||
        public ISelectGrouping<TKey, TValue> Count(out long count)
 | 
			
		||||
        {
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										25
									
								
								FreeSql/Internal/Model/BasePagingInfo.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								FreeSql/Internal/Model/BasePagingInfo.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,25 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Text;
 | 
			
		||||
 | 
			
		||||
namespace FreeSql.Internal.Model
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 分页信息
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class BasePagingInfo
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 第几页,从1开始
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public int PageNumber { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 每页多少
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public int PageSize { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 查询的记录数量
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public long Count { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user