Enums or Tables?

后端 未结 9 926
天命终不由人
天命终不由人 2021-02-06 08:38

I am making this a community wiki, as I would appreciate people\'s approach and not necessarily an answer.

I am in the situation where I have a lot of lookup type data

9条回答
  •  爱一瞬间的悲伤
    2021-02-06 08:52

    Since C# doesn't allow Enums with string values, so I would suggest a struct with some static strings.

    That way, you maintain some Intellisense, but without trying to shoehorn an Enum value on what is a string value in the database.

    The other solution I would offer: remove the logic that depends on these values and move to table-based logic. (For instance, if each traunch has a different tax rate, add tax rate as a column in the database rather than a case {} in the code.).

提交回复
热议问题