I am designing a web application, as a first step I am creating a database. Now very basic table called Role
which needs to be managed through database. This table will hold:
RoleID (Identity and Primary Key)
RoleName (Varchar)
Now in application if I need to check that for "Admin" role, enable one of the button else disable it. Then how should I write a code without hard coding "Admin" as Role?
What could be a good design in this case for storing Master like data in database and refer to it in application?
I used to do it with enum
earlier but it seems its not much maintainable because if I add new Role in database then I also need to change the enum
in code, e.g.
public enum Role
{
Admin=1,
Normal=2
}