Reputation: 85715
I think my query is not working because of the enum flag I have.
[Flags]
public enum Permissions
{
None = 0,
Read = 1,
Write = 2,
Delete = 4,
Full = 8
}
dbContext.UserStorages.FirstOrDefault(x => x.Permission.HasFlag(Permissions.Write));
In my sql database the column is an "int" column. and right now has a value of "8" if I change it to Permissions.Full then I will get the record back.
Upvotes: 1
Views: 1405
Reputation: 31610
Permissions.Full
shouldn't be 8 but 7 if it means Read + Write + Delete. In binary
Read -> %001
Write -> %010
Delete -> %100
Full -> Read | Write | Delete -> %001 | %010 | %100 -> %111 -> 7
In your case you are asking whether the second bit (i.e. %0010
) is set in %1000
which obviously it isn't.
Upvotes: 1