mirror of
https://github.com/dotnetcore/FreeSql.git
synced 2026-02-03 23:10:54 +08:00
Updated Greed Loading (markdown)
@@ -1,29 +1,30 @@
|
||||
[中文](%e8%b4%aa%e5%a9%aa%e5%8a%a0%e8%bd%bd) | **English**
|
||||
|
||||
## 1、导航属性 ManyToOne
|
||||
## Navigation Properties - ManyToOne
|
||||
|
||||
ManyToOne 导航属性通过 ToList(includeNestedMembers: false) 加载,参数说明:
|
||||
ManyToOne navigation properties are loaded by `ToList(includeNestedMembers: false)`, parameter description:
|
||||
|
||||
false: 返回 2级 Join 的导航数据(默认);
|
||||
`false`: Return the navigation data of Level 2 Join (default);
|
||||
|
||||
true: 返回所有层级深度 Join 的导航数据(未使用的导航数据不会返回);
|
||||
`true`: Return the navigation data of all levels of depth Join (unused navigation data will not be returned).
|
||||
|
||||
```csharp
|
||||
Select<Tag>().Include(a => a.Parent.Parent).ToList(true);
|
||||
|
||||
Select<Tag>().Where(a => a.Parent.Parent.Name == "1").ToList(true);
|
||||
//这样写,不需要再标记 Join,解析表达式时自动处理成 LeftJoin
|
||||
//Write in this way, no need to mark Join,
|
||||
//it will be automatically processed into LeftJoin when parsing the expression
|
||||
```
|
||||
|
||||
## 2、导航属性 OneToMany/ManyToMany
|
||||
## Navigation Properties - OneToMany/ManyToMany
|
||||
|
||||
IncludeMany 贪婪加载集合的导航属性,其实是分两次查询,在 ToList 后进行了数据重装。
|
||||
IncludeMany greedily loads the navigation properties of the collection. In fact, it is queried twice, and data is assembled after `ToList`.
|
||||
|
||||
```csharp
|
||||
Select<Tag>().IncludeMany(a => a.Songs).ToList();
|
||||
```
|
||||
|
||||
IncludeMany 有第二个参数,可以进行二次查询前的修饰工作。
|
||||
IncludeMany has a second parameter, which can be modified before the second query.
|
||||
|
||||
```csharp
|
||||
Select<Tag>().IncludeMany(a => a.Songs,
|
||||
|
||||
Reference in New Issue
Block a user