diff --git a/With-Sql.md b/With-Sql.md index 7a1d9a5..5cbe33a 100644 --- a/With-Sql.md +++ b/With-Sql.md @@ -118,11 +118,11 @@ SELECT ID, Age ``` -## 通过 WithSql+ ToSQL实现 Union ALL 查询方法 +## WithSql+ ToSQL = Union ALL -### 1、二次 ISelect 查询:WithSql 使用多次,等于 UNION ALL 查询 +### Two-Stage ISelect Query: Use WithSql Multiple Times to Convert to UNION ALL Query -WithSql 使用多次为 UNION ALL 查询,所以我们可以利用 ISelect.ToSql(FieldAliasOptions.AsProperty) 得到生成的 SQL,如下: +After using `WithSql` multiple times, a query statement based on `UNION ALL` will be generated. So we can use `ISelect.ToSql(FieldAliasOptions.AsProperty)` to get the generated SQL as follows: ```csharp var sql1 = fsql.Select() @@ -154,9 +154,11 @@ FROM ( SELECT a.`Id`, a.`Clicks`, a.`TypeGuid`, a.`Title`, a.`CreateTime` ### 2、跨分表查询:AsTable 相同实体多次操作,等于 Union ALL 查询 +### Cross Sub-Table Query: Wse AsTable for the Same Entity Multiple Times to Convert to UNION ALL Query + ```c# var sql = fsql.Select() - .AsTable((type, oldname) => "table_1")a + .AsTable((type, oldname) => "table_1") .AsTable((type, oldname) => "table_2") .ToSql(a => a.Id); ``` @@ -167,7 +169,7 @@ UNION ALL select * from (SELECT a."Id" as1 FROM "table_2" a) ftb ``` -### 3、利用 ToSql 拼接新的 SQL,使用 IAdo 执行 +### Use ToSql to Splice New SQL Statements, And Use IAdo to Execute ```c# var sql1 = fsql.Select() @@ -183,8 +185,9 @@ fsql.Ado.CommandFluent($"{sql1} UNION ALL {sql2}") -## 分页问题 -Union All 之后 如果直接 分页会有一个问题。请看具体示例 +## Paging Problem + +After using `UNION ALL`, there will be a problem if you paginate directly. Please see the specific example: ### 多次WithSql+Page存在问题:每个WithSql内都有一个Page分页