You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
|
|
|
|
|
|
namespace Common.Repository.Core
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 主键为字符串的实体基类,为系统默认的实体类型
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class UserEntity : BaseEntity
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Browsable(false)]
|
|
|
|
|
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
|
|
|
|
public int UserID { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 判断主键是否为0,常用做判定操作是【添加】还是【编辑】
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public override bool KeyIsNull()
|
|
|
|
|
{
|
|
|
|
|
return UserID == 0;
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public override void GenerateDefaultKeyVal()
|
|
|
|
|
{
|
|
|
|
|
//主键自动增长类型,可以不用该方法生成主键,设置该方法为空方法即可
|
|
|
|
|
//当DbContext执行SaveChanges()后,如果添加成功,可以直接获取对象的Id
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|