mirror of
https://github.com/dotnetcore/FreeSql.git
synced 2026-02-21 07:40:57 +08:00
update
13
动态操作.md
13
动态操作.md
@@ -99,20 +99,21 @@ fsql.Select<Region>().OrderBy("a.id desc") //提示:存在SQL注入安全问
|
||||
|
||||
```csharp
|
||||
fsql.Select<Region>()
|
||||
.IncludeByPropertyName("Parent.Parent.Parent") //ManyToOne/OneToOne
|
||||
.IncludeByPropertyName("Childs") //OneToMany/ManyToMany/PgArrayToMany
|
||||
.IncludeByPropertyName("Parent.Parent.Parent")
|
||||
.IncludeByPropertyName("Childs")
|
||||
|
||||
.IncludeByPropertyName("Childs", then => then
|
||||
.IncludeByPropertyName("Parent.Parent")
|
||||
.IncludeByPropertyName("Parent.Childs")) //向下加载,可以向下 100 层
|
||||
.IncludeByPropertyName("Parent.Childs"))
|
||||
.ToList();
|
||||
```
|
||||
|
||||
2、List\<TDto\>.IncludeByPropertyName 扩展方法也实现了 OneToMany 动态贪婪加载:
|
||||
|
||||
> 非实体类型,也可以级联加载,他们不需要配置导航属性关系。
|
||||
|
||||
```csharp
|
||||
var dtos = fsql.Select<Region>().ToList<Dto>();
|
||||
//非实体类型,也可以级联加载,他们不需要配置导航属性关系
|
||||
|
||||
dtos.IncludeByPropertyName(
|
||||
orm: fsql,
|
||||
@@ -138,8 +139,8 @@ List<(int, string)> list = fsql.Select<Region>()
|
||||
```csharp
|
||||
DataTable dt = fsql.Select<Region>()
|
||||
.ToDataTableByPropertyName(new [] {
|
||||
"Parent.Code", //导航属性模式
|
||||
"b.Id" //多表查询模式
|
||||
"Parent.Code",
|
||||
"b.Id"
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user