-
Notifications
You must be signed in to change notification settings - Fork 455
Entity
shuxin edited this page Oct 30, 2023
·
5 revisions
实体为纯 POCO,支持可空类型以及枚举类型映射。
public enum Gender
{
Male = 1,
Female = 2
}
[TableAttribute("Person")]
public class Person
{
[Column(IsPrimaryKey = true)]
public int Id { get; set; }
[Column(DbType = DbType.String)]
public string Name { get; set; }
[Column(DbType = DbType.Int32)]
public Gender? Gender { get; set; }
public int? Age { get; set; }
public int? CityId { get; set; }
/// <summary>
/// 更新实体时不更新此字段
/// </summary>
[UpdateIgnoreAttribute]
public DateTime CreateTime { get; set; } = DateTime.Now;
public DateTime? EditTime { get; set; }
[NotMapped]
public string NotMapped { get; set; } //不映射任何字段
//[Column(IsRowVersion = true)]
//public int RowVersion { get; set; }
/* 1:1,注:PersonEx 那边也要做相应的配置 */
[Navigation("Id")]
public PersonEx Ex { get; set; }
/* 1:1,注:City 那边也要做相应的配置 */
[NavigationAttribute("CityId")]
public City City { get; set; }
}
public class PersonEx
{
/* 1:1,注:Person 那边也要做相应的配置 */
[Navigation("Id")]
public Person Owner { get; set; }
[Column(IsPrimaryKey = true)]
[NonAutoIncrement]
public int Id { get; set; }
public string IdNumber { get; set; }
public DateTime? BirthDay { get; set; }
}
public class City
{
public int Id { get; set; }
public string Name { get; set; }
public int ProvinceId { get; set; }
/* 1:1,注:Province 那边也要做相应的配置 */
[NavigationAttribute("ProvinceId")]
public Province Province { get; set; }
/* 1:N,注:Person 那边也要做相应的配置 */
[NavigationAttribute]
public List<Person> Persons { get; set; } = new List<Person>();
}
public class Province
{
public int Id { get; set; }
public string Name { get; set; }
/* 1:N,注:City 那边也要做相应的配置 */
[NavigationAttribute]
public List<City> Cities { get; set; } = new List<City>();
}
除了使用特性的方式配置映射关系外,还支持 Fluent mapping,详情参考 https://github.com/shuxinqin/Chloe/wiki/Fluent-mapping
熬夜的时候容易引起脱发,熬夜时人的免疫力会下降,还会引起内分泌的变化,导致皮脂分泌增多,这些因素都不利于头发的生长,有可能引起脱发。如果出现熬夜脱发的情况,需要及时纠正日常的生活习惯,合理安排休息时间,早睡早起,适当的锻炼身体,多进食优质的蛋白质,增强身体的抵抗力,促进头发的生长。
发量有限,远离996!!!