In C#, I'm storing a flags enum value in a database as a byte. For example, for the following Flags enum:
[Flags]
public enum Options
{
None = 0,
First = 1,
Second = 2,
Third = 4
}
If I want to record 'First' and 'Second', I save this as a byte of '3' in the 'options' field of a record in the database.
So when using LINQ, how can I check if the value in the database matches 'any' of the options in an argument passed as an 'Options' enum, something like this pseudocode:
public static Something(Options optionsToMatch)
{
db.MyEntity.Get(a => a.options contains any of the options in optionsToMatch);