There is one big thing that makes your code hard to refactor to something prettier namely the ContentFields
enum. It contains two values that are incompatible with the model:
ContentFields.TrainingEvent
vs.model.TrainingEvents
ContentFields.VideoContent
vs.model.HtmlSnippets
This makes it practically impossible to build the SqlCommand
dynamicly or to get the properties by reflection.
If you cannot rename the values you might consider adding custom attributes and get the right name from there (refer to Getting attributes of Enum's value Getting attributes of Enum's value and Creating Custom Attributes:
ContentField
{
[ModelPropertyName("TrainingEvents")]
TrainingEvent
}
The last thing is the name of the ContentFields
enum. If it's not marked with the [Flags]
attribute (you're not using it like that) then it shouldn't be in plural.
There is one big thing that makes your code hard to refactor to something prettier namely the ContentFields
enum. It contains two values that are incompatible with the model:
ContentFields.TrainingEvent
vs.model.TrainingEvents
ContentFields.VideoContent
vs.model.HtmlSnippets
This makes it practically impossible to build the SqlCommand
dynamicly or to get the properties by reflection.
If you cannot rename the values you might consider adding custom attributes and get the right name from there (refer to Getting attributes of Enum's value and Creating Custom Attributes:
ContentField
{
[ModelPropertyName("TrainingEvents")]
TrainingEvent
}
The last thing is the name of the ContentFields
enum. If it's not marked with the [Flags]
attribute (you're not using it like that) then it shouldn't be in plural.
There is one big thing that makes your code hard to refactor to something prettier namely the ContentFields
enum. It contains two values that are incompatible with the model:
ContentFields.TrainingEvent
vs.model.TrainingEvents
ContentFields.VideoContent
vs.model.HtmlSnippets
This makes it practically impossible to build the SqlCommand
dynamicly or to get the properties by reflection.
If you cannot rename the values you might consider adding custom attributes and get the right name from there (refer to Getting attributes of Enum's value and Creating Custom Attributes:
ContentField
{
[ModelPropertyName("TrainingEvents")]
TrainingEvent
}
The last thing is the name of the ContentFields
enum. If it's not marked with the [Flags]
attribute (you're not using it like that) then it shouldn't be in plural.
There is one big thing that makes your code hard to refactor to something prettier namely the ContentFields
enum. It contains two values that are incompatible with the model:
ContentFields.TrainingEvent
vs.model.TrainingEvents
ContentFields.VideoContent
vs.model.HtmlSnippets
This makes it practically impossible to build the SqlCommand
dynamicly or to get the properties by reflection.
If you cannot rename the values you might consider adding custom attributes and get the right name from there (refer to Getting attributes of Enum's value and Creating Custom Attributes:
ContentField
{
[ModelPropertyName("TrainingEvents")]
TrainingEvent
}
The last thing is the name of the ContentFields
enum. If it's not marked with the [Flags]
attribute (you're not using it like that) then it shouldn't be in plural.