-1

I am just starting out with CodeFluent and beginning to really like it. My question is: I set a property of an entity to enumeration. How can I allow an end-user to add extra values (that are stored afterwards as additional choices) to an enumeration? Or should I use another entity to store those values/choices instead?

For instance: let's say I have a product and a producttype. My producttype is an enumeration (frozen, fresh, seasonal), and down the road, the user wants additional types (i.e.: organic, stationary). Should those be enumeration values or a separate entity?

If a separate entity.....I'm not really sure how I define the relationship (1 to 1, 1 to many - i.e. 1 producttype can have many products)?

Simon Mourier
  • 132,049
  • 21
  • 248
  • 298
njtaz76
  • 1
  • 1
  • [How to create a Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve) – buhtz Sep 17 '16 at 21:18

1 Answers1

0

You can't add values to an enum at runtime, that's impossible in .NET, so it's also impossible with CodeFluent.

So, you want to create another entity that will store the list of enums. That would be a 1:M relation. This is how you would layout that relation:

enter image description here

Each enumeration value would be a row in the ProductType table. With CodeFluent, you can declare "instances" for an entity that will become rows in the final table, so here, you can declare your initial enum values using instance, so use the instance grid on the ProductType entity, and add instances:

enter image description here

Note in this case, maybe you want to create the ProductType's Id property as an int without identity (if you don't want those enum int values generated by the database).

Simon Mourier
  • 132,049
  • 21
  • 248
  • 298