Save Flag Enums in SQL Database and EF6. Is this possible?

后端 未结 3 1790
独厮守ぢ
独厮守ぢ 2020-12-31 16:35

On an ASP.NET application I have a flag enum as follows:

[Flags]
enum Target : int {
  None = 0,
  Group = 1,
  Student = 2,
  Professor = 4,
  All = Group |         


        
3条回答
  •  轮回少年
    2020-12-31 17:06

    The only difference between enum types with and without HasFlagAttribute is how they are written when using .ToString() (and maybe how they are parsed when using Enum.Parse). EF internally strips the information about enum type and is only using the underlying enum type (accounting for nullability).

提交回复
热议问题