Wish: Flag Option for Type Table

Feb 26, 2011 at 4:57 AM

Would it be possible to make whether or not the enum generated from a Type Table is a set of flags (i.e., have the enum decorated with the Flag attribute)? I find I use enums as flags about half the time.

Coordinator
Feb 26, 2011 at 1:15 PM

This not something that we will do soon. This requires a model change and some validation rules associated with it. It is something we might explore but right now we are full trying to get more templates out and rework the existing ones. What would adding an attribute to the enum buy you? What would you do with it? Please explain how you want to use it.

Feb 26, 2011 at 3:16 PM

Right now the enum that gets generated cannot be used as a set of flags:

[Flags]
public enum AccessRights
{
Add = 1,
Edit = 2,
Delete = 4
}

if( (user.AccessRights &  AccessRights.Delete) ) ... allow deletion

Coordinator
Feb 26, 2011 at 7:10 PM

I know how to use the bit flags; I was just wondering why you need an attribute on th enum to tell you that it is an bit flag. Since you are the one who built the model, you know that it is a bit flag. You can build code just like that now. I am confused what adding another attribute to the enumeration would matter.