Updated With Sql (markdown)

AlexLEWIS
2021-09-27 13:55:12 +08:00
parent 4aa9c765dd
commit ccc787892a

@@ -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.