Best way to save type of class in database?

后端 未结 3 966
无人及你
无人及你 2020-12-21 10:53

What is a good way to denote \"type\" in database?

I have a base class Action which is inherited by numerous child classes. Actio

3条回答
  •  情歌与酒
    2020-12-21 11:28

    I would go with your first option and use reflection. It seems more likely that you will want to add new action types rather than change existing class names and therefore the ease of serializing the type using reflection is more useful. You could then just have a utility class for serializing actions and restoring them from their type string.

提交回复
热议问题