mirror of
https://github.com/dotnetcore/FreeSql.git
synced 2026-02-05 07:50:52 +08:00
update
@@ -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>()
|
||||||
|
|||||||
10
withsql.md
10
withsql.md
@@ -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 *
|
||||||
|
|||||||
Reference in New Issue
Block a user