MySql-实体定义

实体定义

实体为纯 POCO,支持可空类型以及枚举类型映射。

public enum Gender
{
    Man = 1,
    Woman
}
[TableAttribute("Users")]
public class User
{
    [ColumnAttribute("Id", IsPrimaryKey = true)]
    public int Id { get; set; }
    public string Name { get; set; }
    public Gender? Gender { get; set; }
    public int? Age { get; set; }
    public int? CityId { get; set; }
    public DateTime? OpTime { get; set; }

    [NotMappedAttribute]
    public string NotMappedProperty { get; set; }
}
public class City
{
    public int Id { get; set; }
    public string Name { get; set; }
    public int ProvinceId { get; set; }
}
public class Province
{
    public int Id { get; set; }
    public string Name { get; set; }
}