john

john

  • NA
  • 12
  • 0

Enums ?? Database ??

Oct 6 2003 10:07 AM
I have a simple question but one that has confused me for sometime now. I'll use a simple sample here to explain my problem. Lets say I have a simple database which as 3 tables in it. Users, Roles, UserRoles. I will assume that everyone can see the relationship between these tables. In my c# code I have the way to add a new user also to the db. I also have methods within my code which allow the user to create new roles. When I add a new user I would like to expose a enumeration of userroles. public int AddUser(string userName, UserRoles role) //example method to add user My question is a how can I keep my enumeration sync'd with my database roles? I would think that there should be a way to do this but the only thing that I can think of is dynamically creating the enumeration. But when I think about this, how would that work. I give someone my class to user, when they do a myobject obj = new myobject(); how to i get the enumerations at that time. Hope I have supplied enough information for someone to help me out on this problem. Any help or input on this problem would be greatly appreciated. I can see where this issues might arise is serveral situations. John Hidey

Answers (8)