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(); .ExecuteDataTable();
``` ```
## Paging Problem ## Paging Problem
After using `UNION ALL`, there will be a problem if you paginate directly. Please see the specific example: 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 ```csharp
var sql1 = fsql.Select<Topic>() var sql1 = fsql.Select<Topic>()

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