What is the best approach for storing database table IDs that are used often?
For example you have a table that stores Record statuses, such as active deleted, purged etc. You want to create a new User record and you need to set the RecordStatusID, where would you get that data? Do a database call?
I’ve seen developers create enums that matches the tables int IDs, but I don’t think that is the best way.
If your application logic depends on those values, and so changing the table means changing your code, I prefer creating enums that mirror the table.
Doing this creates readable code with no need for magic strings that could contain a typo (although you replace them with magic numbers in the enum definition). And the code is efficient without unnecessary queries.