update

2881099
2022-04-30 11:03:31 +08:00
parent 2707f7ad5b
commit 0255fe7df9
2 changed files with 108 additions and 109 deletions

@@ -183,14 +183,11 @@ fsql.Ado.CommandFluent($"{sql1} UNION ALL {sql2}")
.ExecuteDataTable();
```
## Paging Problem
After using `UNION ALL`, there will be a problem if you paginate directly. Please see the specific example:
### There is a problem with using WithSql + Page multiple times: There is a paging statement in each WithSql
There is a problem with using WithSql + Page multiple times: There is a paging statement in each WithSql
```csharp
var sql1 = fsql.Select<Topic>()

@@ -187,13 +187,12 @@ fsql.Ado.CommandFluent($"{sql1} UNION ALL {sql2}")
.ExecuteDataTable();
```
## 分页问题
Union All 之后 如果直接 分页会有一个问题。请看具体示例
多次 WithSql + Page 存在问题每个WithSql内都有一个Page分页
### 多次WithSql+Page存在问题每个WithSql内都有一个Page分页
```csharp
var sql1 = fsql.Select<Topic>()
.Where(a => a.Title.Contains("xxx"))
@@ -230,7 +229,8 @@ WithSql 可以和 AsTable 实现分表的功能。
## 解决方案
### 多次withsql如需分页需要按下面的二步操作
多次 withsql ,如需分页,需要按下面的二步操作
- 第一步通过witsql将二个sql组成一个sql。
```csharp
@@ -253,12 +253,14 @@ WithSql 可以和 AsTable 实现分表的功能。
```
- 第二步:之后 调用 Page 则是通过 Union ALL 后的结果上分页
```csharp
var sql2 = g.mysql.Select<Topic>()
.WithSql(sql)
.Page(2, 10)
.ToSql();
```
```sql
SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime`
FROM ( SELECT * from (SELECT *