mirror of
https://github.com/dotnetcore/FreeSql.git
synced 2026-02-03 23:10:54 +08:00
Page:
Pagination
Pages
ADO
AOP
API
BaseEntity
Cascade Deletion
Cascade Saving
CodeFirst
DI UnitOfWorkManager
Dapper比较
DbContext
DbFirst
Delete Data
Dynamic Operations
Entity Relationship
EntityFramework比较
FluentApi
Getting Started
Greed Loading
Group Aggregation Query
Home
Import Entity Configuration from Database
Insert Data
Insert or Update
Install
Lazy Loading
Linq to Sql
LinqToSql
Nested Query
Pagination
Parent Child Relationship Query
Query Data
Query from Multi Tables
Query from Single Table
Repository Layer
Repository
Return Data
Unit of Work
Update Data
With Sql
withsql
事务
修改
入门
分组聚合查询
分表分库
分页查询
删除
动态操作
单表查询
多表查询
安装
实体关系
实体特性
导入数据库特性
嵌套查询
工作单元
常见问题
延时加载
性能
支持我们
更新日志
查询
查询父子关系
添加
添加或修改
租户
类型映射
联合查询
联级保存
联级删除
聚合根(实验室)
自定义特性
表达式函数
读写分离
贪婪加载
过滤器
返回数据
首页
骚操作
Clone
9
Pagination
2881099 edited this page 2023-11-22 19:58:29 +08:00
Table of Contents
中文 | English
static IFreeSql fsql = new FreeSql.FreeSqlBuilder()
.UseConnectionString(FreeSql.DataType.MySql, connectionString)
.Build(); //Be sure to define as singleton mode
class Topic {
[Column(IsIdentity = true)]
public int Id { get; set; }
public string Title { get; set; }
public int Clicks { get; set; }
public DateTime CreateTime { get; set; }
public int CategoryId { get; set; }
}
20 data per page, query page 1
var list = fsql.Select<Topic>()
.Where(a => a.Id > 10)
.Count(out var total) //Total number of records
.Page(1, 20)
.Tolist();
Count(out var total) is a synchronous method, because out does not support asynchrony. If you mind, you can execute it separately as follows:
var select = fsql.Select<Topic>()
.Where(a => a.Id > 10);
var total = await select.CountAsync();
var list = await select.Page(1, 20).ToListAsync();
Optimization
For the previous versions of SqlServer 2012, use row_number for pagination;
For SqlServer 2012+ version, using the latest fetch next rows pagination;
API
| Methods | Return | Parameters | Description |
|---|---|---|---|
| ToSql | string | Return the SQL statement to be executed | |
| ToList | List<T1> | Execute SQL query, and return the records of all the fields of the T1 entity. If there are navigation properties, they will be queried and returned together. If the record does not exist, a list with Count of 0 will be returned. |
|
| ToList<T> | List<T> | Lambda | Execute SQL query, and return the record of the specified fields. If the record does not exist, a list with Count of 0 will be returned. |
| ToList<T> | List<T> | string field | Execute SQL query, and return the record of the specified fields of the parameters, and receive it as a tuple or basic type (int, string, long). If the record does not exist, a list with Count of 0 will be returned. |
| 【Pagination】 | |||
| Count | long | Number of records queried | |
| Count | <this> | out long | The number of records to be queried, returned in the form of parameter with out |
| Skip | <this> | int offset | Query the number of rows shifted backward |
| Offset | <this> | int offset | Query the number of rows shifted backward |
| Limit | <this> | int limit | Number of query data |
| Take | <this> | int limit | Number of query data |
| Page | <this> | int pageIndex, int pageSize | Pagination |
Reference
Basic
- 入门 Getting Started
- 安装 How to Install
- 添加 Insert Data
- 删除 Delete Data
- 修改 Update Data
- 添加或修改 Insert or Update ✨
- 查询 Query Data
- 仓储层 Repository Layer
- CodeFirst
- DbFirst
- 表达式函数
- 事务
- 过滤器
- ADO
- AOP✨
- 读写分离
- 分表分库
- 租户
- 性能
- 动态操作 Dynamic Operations
- 你不知道的功能✨
- API参考