Dome wrote:
Otis wrote:
It's not as easy as it might look. If I do:
public enum CustomerType
{
Foo,
Bar
}
this is set in stone in the application. If I then change any value in the CustomerType lookup table, I get mismatches, also when I add a value to the lookup table, for example because another application on the same db requires it. I.o.w.: it's pretty fragile.
Sure, but that's just a case of managing your lookup tables, right?
Sure, if no-one makes mistakes, things will go OK
. The problem is that the values are actually stored at two places: in the code and in the db.
I mean, if it's really a lookup table, there's problably some code logic like "if (customer.Type == CustomerType.BigCustomer) ...". If these tables change, the code logic probably also needs to change. So it would require a rebuild of your solution anyway, at which time you can regenerate your enums...right?
I'm not denying that when everything is done as planned everything works, however reality doesn't work that way.
Now, for your convenience, someone has written a task performer for enum generation. (which is executed as a task during code generation). THis task performer was made for v2.0, but should work ok with later versions with perhaps a few modifications (source is provided). It's available to customers.