-
Notifications
You must be signed in to change notification settings - Fork 3
Enumerations
To add an enumeration two extra lines are required. The first defines the enum attributes and the second how each item in the enumeration will be created.
Keywords Enum and Template must always appear together or not at all.
The example below shows an enum definition with all options specified.
The resulting code file...
Enum accepts between one and four parameters. The order is not important but the name of the enum is required.
The flags parameter adds the [Flags] attribute to the enum to allow bitwise operators.
The base type can be specified as another parameter. The default value is int as the base type.
Valid types are byte, sbyte, short, Int16, ushort, int, Int32, uint, long, Int64 and ulong.
The remaining parameter is the access modifier. This is either public or internal. The default is public.
As mentioned, order is not important and the following is valid.
Template determines how each item in the enumeration is created.
Each item in the template must be a valid name from the column list.
For a basic enumeration use...
Which creates...
to add initializer values...
or to add a description...
and for a description and initializer...
Finally, the product table defined below has no columns that are suitable for creating an enumeration.
ID cannot be used as it starts with a number, and ProductName contains spaces.
In this case create another column with a suitable enumeration name and put an asterisk immediately after the column name.
The asterisk lets the parser know that this column should be ignored when creating the sql file. Only ID and ProductName will be created in the sql file.