Id字段上的DbKey就是自定义特性
///
/// 用户信息
///
public class User
{
[DbKey]
public string Id { get; set; }
public string Name { get; set; }
}
继承Attribute,实现自定义特性DbKey
namespace CustomerAttribute
{
///
/// 数据库主键
///
public class DbKey : Attribute
{
public string Description { get; set; }
public DbKey()
{
}
public DbKey(string description)
{
this.Description = description;
}
}
}
namespace CustomerAttribute
{
///
/// 用户信息
///
public class User
{
[DbKey]
public string Id { get; set; }
public string Name { get; set; }
}
///
/// 用户角色