How will I add enums to a list according to the value I get back from the database, If the value is 1 then add to the list else don’t.
This is what I have more or less:
Permissions = new List<Permission>()
{
((int)data[0]["AllowOverride"] == 1 ? Permission.AllowOverride : "I do not have an else")
((int)data[0]["AllowAttachment"] == 1 ? Permission.AllowAttachment: "I do not have an else")
},
EDIT: I am constructing this list as part of an object initializer.
You can try setting the property based on the result of a lambda function, which negates the necessity of a separate function to construct the permissions. You can try something along the lines of:
EDIT: I just changed some variable names so it would actually compile without conflicting with your “data” variable already in use.