0

How to Create a Helper to update my enum list from the database. When a new item is added to the database, update my enum as soon as the developer updates his project (rebuild).

Note: It does not necessarily need to be a Database, it can be an external file, for example "TXT".

  • 3
    Not clear what you're asking. Also, C# or VB.Net? WinForms or ASP.Net? – Jimi Oct 05 '21 at 12:37
  • 1
    Broadly speaking, you don't. – gilliduck Oct 05 '21 at 12:40
  • 2
    You could use code generation techniques like T4 or Source Generators. E.g. linq2db generates C# classes by querying a database. T4 templates only run when explicitly invoked, whereas Source Generators run on every build. However because of this, Source Generators should only do things which are very fast: reading from a file is fine, but reading from a database is not. T4 templates can do more complex things, such as querying a database. – canton7 Oct 05 '21 at 12:47
  • If you accept values in an external .txt-file, why not a .cs-file? What is the actual use case? What should happen if the database or file cannot be accessed, or does not have values that the existing code uses? – JonasH Oct 05 '21 at 14:13

0 Answers0