SQL Table and C# Enumeration

前端 未结 4 1472
北恋
北恋 2020-12-28 17:33

Suppose I have n types of users in my application.

I am using an UserType enumeration to distinguish them.

Do I need to keep a table in

4条回答
  •  不知归路
    2020-12-28 18:21

    Often in practice you have a table in the database and the corresponding enumeration in the source code.

    Enumeration makes it easy for you to work with values that otherwise would not have sense to you.

    Having a table in the database lets you perform queries and see in results values that make sense + enforce data integrity (foreign keys).

    The challenge here is to keep the table values synchronized with those of the enumeration. But it works well in practice.

提交回复
热议问题