mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-18 20:08:15 +08:00
- 增加 Navigate 属性未设置 set 时的友好错误提示;
- 增加 延时属性重写类对 protected set 的支持;
This commit is contained in:
52
Examples/base_entity/Test01/Role.cs
Normal file
52
Examples/base_entity/Test01/Role.cs
Normal file
@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using FreeSql.DataAnnotations;
|
||||
using FreeSql;
|
||||
|
||||
namespace EMSServerModel.Model
|
||||
{
|
||||
/// <summary>
|
||||
/// <20><>ɫ<EFBFBD><C9AB>
|
||||
/// </summary>
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public partial class Role : BaseEntity<Role>{
|
||||
/// <summary>
|
||||
/// <20><>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
[JsonProperty, Column(IsPrimary = true, IsIdentity = true)]
|
||||
public long RoleId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// <20><>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
[JsonProperty, Column(DbType = "varchar(50)")]
|
||||
public string RoleName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// <20><>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
[JsonProperty, Column(DbType = "varchar(50)")]
|
||||
public string RoleDesc { get; set; } = string.Empty;
|
||||
|
||||
///// <summary>
|
||||
///// <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
///// </summary>
|
||||
//[JsonProperty, Column(DbType = "date")]
|
||||
//public DateTime CreateTime { get; set; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
[JsonProperty]
|
||||
public bool IsEnable { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// <20><>ɫ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>Զർ<D4B6><E0B5BC>
|
||||
/// </summary>
|
||||
[Navigate(ManyToMany = typeof(UserRole))]
|
||||
public virtual ICollection<User> Users { get; protected set; }
|
||||
|
||||
}
|
||||
|
||||
}
|
154
Examples/base_entity/Test01/User.cs
Normal file
154
Examples/base_entity/Test01/User.cs
Normal file
@ -0,0 +1,154 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using FreeSql.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using FreeSql;
|
||||
|
||||
namespace EMSServerModel.Model
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户表
|
||||
/// </summary>
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public partial class User : BaseEntity<User, long>{
|
||||
|
||||
//[JsonProperty, Column(IsIdentity = true)]
|
||||
//public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 编号
|
||||
/// </summary>
|
||||
[JsonProperty, Column(DbType = "varchar(50)", IsPrimary = true)]
|
||||
public string UserId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 头像
|
||||
/// </summary>
|
||||
[JsonProperty, Column(DbType = "varchar(50)")]
|
||||
public string Avatar { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 姓名
|
||||
/// </summary>
|
||||
[JsonProperty, Column(DbType = "varchar(50)")]
|
||||
public string UserName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 艺名
|
||||
/// </summary>
|
||||
[JsonProperty, Column(DbType = "varchar(50)")]
|
||||
public string NickName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 电话
|
||||
/// </summary>
|
||||
[JsonProperty, Column(DbType = "varchar(50)")]
|
||||
public string Tel { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 性别
|
||||
/// </summary>
|
||||
[JsonProperty]
|
||||
public Sex Sex { get; set; } = Sex.男;
|
||||
|
||||
/// <summary>
|
||||
/// 证件号
|
||||
/// </summary>
|
||||
[JsonProperty, Column(DbType = "varchar(50)")]
|
||||
public string UID { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 生日
|
||||
/// </summary>
|
||||
[JsonProperty, Column(DbType = "date")]
|
||||
public DateTime? DateOfBirth { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 出生地
|
||||
/// </summary>
|
||||
[JsonProperty, Column(DbType = "varchar(50)")]
|
||||
public string PlaceOfBirth { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 居住地
|
||||
/// </summary>
|
||||
[JsonProperty, Column(DbType = "varchar(50)")]
|
||||
public string Addr { get; set; } = string.Empty;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 密码
|
||||
/// </summary>
|
||||
[JsonProperty, Column(DbType = "varchar(50)")]
|
||||
public string Pwd { get; set; } = string.Empty;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 部门编号
|
||||
/// </summary>
|
||||
[JsonProperty]
|
||||
public long? DeptId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 职务编号
|
||||
/// </summary>
|
||||
[JsonProperty]
|
||||
public long? TitleId { get; set; }
|
||||
|
||||
|
||||
///// <summary>
|
||||
///// 创建时间
|
||||
///// </summary>
|
||||
//[JsonProperty, Column(DbType = "date")]
|
||||
//public DateTime CreateTime { get; set; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// 国籍
|
||||
/// </summary>
|
||||
[JsonProperty, Column(DbType = "varchar(50)")]
|
||||
public string Nationality { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 经手人
|
||||
/// </summary>
|
||||
[JsonProperty, Column(DbType = "varchar(50)")]
|
||||
public string Handler { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 启用
|
||||
/// </summary>
|
||||
[JsonProperty]
|
||||
public bool IsEnable { get; set; } = true;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
[JsonProperty, Column(DbType = "varchar(100)")]
|
||||
public string Memos { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Navigate(ManyToMany = typeof(UserRole))]
|
||||
public virtual ICollection<Role> Roles { get; protected set; }
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 性别枚举
|
||||
/// </summary>
|
||||
public enum Sex
|
||||
{
|
||||
/// <summary>
|
||||
/// 女=0
|
||||
/// </summary>
|
||||
女=0,
|
||||
/// <summary>
|
||||
/// 男=1
|
||||
/// </summary>
|
||||
男=1
|
||||
}
|
||||
|
||||
}
|
36
Examples/base_entity/Test01/UserRole.cs
Normal file
36
Examples/base_entity/Test01/UserRole.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using Newtonsoft.Json;
|
||||
using FreeSql.DataAnnotations;
|
||||
using FreeSql;
|
||||
|
||||
namespace EMSServerModel.Model
|
||||
{
|
||||
/// <summary>
|
||||
/// <20>û<EFBFBD><C3BB><EFBFBD>ɫ<EFBFBD><C9AB>ϵ<EFBFBD><CFB5>
|
||||
/// </summary>
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public partial class UserRole : BaseEntity<UserRole>{
|
||||
/// <summary>
|
||||
/// <20><>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
[JsonProperty]
|
||||
public long RoleId { get; set; }
|
||||
/// <summary>
|
||||
/// <20><>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
[Navigate("RoleId")]
|
||||
public Role Roles { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// <20>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
[JsonProperty, Column(DbType = "varchar(50)")]
|
||||
public string UserId { get; set; }
|
||||
/// <summary>
|
||||
/// <20>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
[Navigate("UserId")]
|
||||
public User Users { get; set; }
|
||||
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user