mirror of
https://github.com/dotnetcore/FreeSql.git
synced 2026-02-03 23:10:54 +08:00
Updated With Sql (markdown)
15
With-Sql.md
15
With-Sql.md
@@ -152,8 +152,6 @@ FROM ( SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime`
|
|||||||
WHERE ((a.`Title`) LIKE '%yyy%') ) a) ftb
|
WHERE ((a.`Title`) LIKE '%yyy%') ) a) ftb
|
||||||
```
|
```
|
||||||
|
|
||||||
### 2、跨分表查询:AsTable 相同实体多次操作,等于 Union ALL 查询
|
|
||||||
|
|
||||||
### Cross Sub-Table Query: Wse AsTable for the Same Entity Multiple Times to Convert to UNION ALL Query
|
### Cross Sub-Table Query: Wse AsTable for the Same Entity Multiple Times to Convert to UNION ALL Query
|
||||||
|
|
||||||
```c#
|
```c#
|
||||||
@@ -190,7 +188,8 @@ fsql.Ado.CommandFluent($"{sql1} UNION ALL {sql2}")
|
|||||||
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:
|
||||||
|
|
||||||
|
|
||||||
### 多次WithSql+Page存在问题:每个WithSql内都有一个Page分页
|
### 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>()
|
||||||
.Where(a => a.Title.Contains("xxx"))
|
.Where(a => a.Title.Contains("xxx"))
|
||||||
@@ -219,15 +218,11 @@ limit 0,20) ftb
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
多个sql union all使用withsql,直接Page分页,会导致每个子表都生效,子表都生成分页。
|
After multiple Sql statements are combined with WithSql (and a `UNION ALL` statement is generated), if you directly use the `Page` method for paging, it will cause a paging statement to be generated in each sub-table.
|
||||||
|
|
||||||
WithSql 可以和 AsTable 实现分表的功能。
|
`WithSql` can realize the function of sub-table with `AsTable`. When querying across sub-tables, paging will take effect in each sub-table (that is, each SQL paging in WithSql).
|
||||||
|
|
||||||
分表跨表查询的时候,分页是要向每个子表(即每个WithSql中的SQL分页)都生效。
|
### Solution: Call WithSql Multiple Times
|
||||||
|
|
||||||
## Solution
|
|
||||||
|
|
||||||
### Call WithSql Multiple Times
|
|
||||||
|
|
||||||
Call WithSql multiple times. If you need to paging, you need to follow the two steps below.
|
Call WithSql multiple times. If you need to paging, you need to follow the two steps below.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user