mirror of
https://github.com/dotnetcore/FreeSql.git
synced 2026-02-04 07:20:51 +08:00
update
15
实体关系.md
15
实体关系.md
@@ -1,3 +1,13 @@
|
||||
导航属性是 FreeSql 的特色功能之一,可通过约定配置、或自定义配置对象间的关系。
|
||||
|
||||
导航属性有 OneToMany, ManyToOne, ManyToMany, OneToOne, Parent 五种配置关系。
|
||||
|
||||
有了导航属性,多表查询会非常方便,lambda 表达式中直接使用导航对象点点点,舒服!!
|
||||
|
||||
- 可约定(命名约定),可不约定(需指定 Navigate 特性关联);
|
||||
- 无关联的,查询时可以指明 On 条件,LeftJoin(a => a.Parent.Id == a.ParentId);
|
||||
- 已关联的,直接使用导航对象就行,On 条件会自动附上;
|
||||
|
||||
# 自定义导航关系
|
||||
|
||||
```csharp
|
||||
@@ -16,11 +26,6 @@ public virtual Song Obj_song { get; set; }
|
||||
public virtual List<tag> tags { get; set; }
|
||||
```
|
||||
|
||||
- 可约定,可不约定;
|
||||
- 不约定的,需指定 Navigate 特性关联;
|
||||
- 无关联的,查询时可以指明 On 条件,LeftJoin(a => a.Parent.Id == a.ParentId);
|
||||
- 已关联的,直接使用导航对象就行,On 条件会自动附上;
|
||||
|
||||
---
|
||||
|
||||
也可以使用 FluentApi 在外部设置导航关系:
|
||||
|
||||
Reference in New Issue
Block a user