mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-19 12:28:15 +08:00
🚀增加分页模型分页及示例
This commit is contained in:
@ -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;
|
||||
|
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