当前位置:网站首页>EF core :自引用的组织结构树
EF core :自引用的组织结构树
2022-07-24 23:55:00 【董厂长】
描述这样一种情况:组织单元形成的一棵树

父节点 and 子节点 也是OrgUnit类型的属性
class OrgUnit
{
public long Id { get; set; }
public string Name { get; set; }
public OrgUnit Parent { get; set; }
public List<OrgUnit> Children { get; set; } = new List<OrgUnit>();
}
EF core的配置
builder.ToTable("T_OrgUnits");
builder.Property(o => o.Name).IsRequired().IsUnicode().HasMaxLength(100);
builder.HasOne<OrgUnit>(u => u.Parent).WithMany(p => p.Children);
复习一下,需要继承自IEntityTypeConfiguration<T>接口。并且实现 Configure方法。



边栏推荐
- 2022 the most NB JVM foundation to tuning notes, thoroughly understand Alibaba P6 small case
- 1、 MFC introduction
- Browser cache
- Processing PDF and JPG files in VB6
- Is the income of CICC securities' new financial products 6%? I want to open an account and manage money
- 芯片的功耗
- Which securities account is the best and safest for beginners
- Use SQLite provided by the system
- 4. Immersion test
- Pointers and arrays
猜你喜欢

凸优化基础知识

2. Load test

Js----- Chapter 4 array

Convert a string to an integer and don't double it

JS ------ Chapter 3 JS cycle

How painful is it to write unit tests? Can you do it

Add a little surprise to life and be a prototype designer of creative life -- sharing with X contestants in the programming challenge

With screen and nohup running, there is no need to worry about deep learning code anymore | exiting the terminal will not affect the operation of server program code

Live broadcast preview | online seminar on open source security governance models and tools

C语言学习之分支与循环语句
随机推荐
Power consumption of chip
Processing of ffmpeg wasapi can't activate audio endpoint error
Wine wechat initialization 96% stuck
Advanced function of postman
Transmission download list, download file migration machine guide
Xiezhendong: Exploration and practice of digital transformation and upgrading of public transport industry
Notes of Teacher Li Hongyi's 2020 in-depth learning series 9
Introduction to HLS programming
代码覆盖率
The new version of SSM video tutorial in shangsilicon valley was released
.net redis client newlife.redis.core library usage
Grafana - influxdb visual K6 output
你还在使用System.currentTimeMillis()?来看看StopWatch吧
C language program environment and preprocessing
Do you need to open an account to buy a wealth management product with a 6% income?
ROS机械臂 Movelt 学习笔记3 | kinect360相机(v1)相关配置
JS ------ Chapter 3 JS cycle
SQLite database operation
Mandatory interview questions: 1. shallow copy and deep copy_ Shallow copy
Be an artistic test / development programmer and slowly change yourself