C # Enums vs Data Managed Lists

I am trying to find a better way to do my project for listing. Say I have a class and an enumeration:

public enum ActionType
{
    Acceptable = 1,
    Unacceptable = 2,
    PendingReview = 3        
}
public class Report
{
    public ActionType Action { get; set; }
}

Let's say I also have a database table that stores different types of actions:

Id     Action
1      Acceptable
2      Unacceptable
3      PendingReview

if I want to add another type of action at a later day, I will need to update the enumeration and update the assemblies. But I like how enumeration reduces errors, simplifies code reading, and provides advanced compatibility. What is an effective way to use new types of actions?

Thank!

+3
source share
4 answers

, , , .

, , , . , , , . DB , , , if (status == 2)...

, , , . . , ClickOnce, .

+2

, , . .

, , .

, . , , .

+5

. log4net.Core.Level( log4net, ) , -, , .

.

+2

, . , , - .

, , , , , .

:

[TestMethod]
public void SomeLookupTest()
{
    LookupGetter getter = new LookupGetter();

    LookupTester.CompareEnumWithDatabase(
        getter.GetItems(LookupName.Schema__SomeLookup),
        typeof(SomeLookupEnumType)
    );
}
+1

Source: https://habr.com/ru/post/1775018/


All Articles