Updated 多表查询 (markdown)

2881099
2020-04-28 17:31:13 +08:00
parent 23a067326d
commit 402aa83d90

@@ -49,18 +49,19 @@ fsql.Select<Topic, Category, CategoryType>()
.LeftJoin((a,b,c) => a.CategoryId == b.Id) .LeftJoin((a,b,c) => a.CategoryId == b.Id)
.LeftJoin((a,b,c) => b.ParentId == c.Id) .LeftJoin((a,b,c) => b.ParentId == c.Id)
.Where((a,b,c) => c.Id > 0) .Where((a,b,c) => c.Id > 0)
.ToList(); .ToList((a,b,c) => new { a,b,c });
//或者 //或者
fsql.Select<Topic>().From<Category, CategoryType>((s, b, c) => s fsql.Select<Topic>().From<Category, CategoryType>((s, b, c) => s
.LeftJoin(a => a.CategoryId == b.Id) .LeftJoin(a => a.CategoryId == b.Id)
.LeftJoin(a => b.ParentId == c.Id)) .LeftJoin(a => b.ParentId == c.Id))
.Where((a,b,c) => c.Id > 0) .Where((a,b,c) => c.Id > 0)
.ToList(); .ToList((a,b,c) => new { a,b,c });
//SELECT a.`Id`, a.`Title`, a.`Clicks`, a.`CreateTime`, a.`CategoryId`, b.`Id` as6, b.`Name`, b.`ParentId` //SELECT ...
//FROM `Topic` a //FROM `Topic` a
//LEFT JOIN `Category` b ON a.`CategoryId` = b.`Id` //LEFT JOIN `Category` b ON a.`CategoryId` = b.`Id`
//LEFT JOIN `CategoryType` c ON b.`ParentId` = c.`Id` //LEFT JOIN `CategoryType` c ON b.`ParentId` = c.`Id`
WHERE c. `Id` > 0
``` ```
## 3、SQL联表 ## 3、SQL联表