我有一个这样的枚举类型Operation
:
[Flags]
public enum Operation
{
None = 0,
View = (1 << 0),
Add = (1 << 1),
Edit = (1 << 2),
Delete = (1 << 3),
ReservedA = (1 << 4),
ReservedB = (1 << 5),
Admin = (View | Add | Edit | Delete)
}
并且表permission
包含一operations
列。该表映射到这样的类:
[Table("rolepermission")]
public class Permission : IComparable
{
private int _id = 0;
private Operation _operations = Operation.None;
private List<UserRole> _roles = null;
public Permission()
{
_roles = new List<UserRole>();
}
[Key]
public int Id
{
get { return _id; }
set { _id = value; }
}
[EnumDataType(typeof(Operation))]
public Operation Operations
{
get { return _operations; }
set { _operations = value; }
}
}
但它不起作用。
有什么优雅的方法可以映射它吗?
我认为创建int
-type 属性不是最好的方法。