Persisting Enums in database tables

后端 未结 5 1318
攒了一身酷
攒了一身酷 2021-01-11 09:43

I have an order which has a status (which in code is an Enum). The question is how to persist this. I could:

  1. Persist the string in a field and then map back t
5条回答
  •  温柔的废话
    2021-01-11 10:26

    I suppose it depends on where the data will be retrieved. With #3, you could retrieve the data without relying on your .NET front end. But it is also possible for your database table to get out of sync with the enum code.

    Option #2 is certainly the most efficient way to do it for storage... but storage is cheap.

提交回复
热议问题