Skip to content

StringEnumField<TStringEnum> class

namespace: Serenity.Data   assembly: Serenity.Net.Services

Field with a string value that is one of the members of a StringEnum type. Like EnumField, a value that is not one of the members is rejected while the value is deserialized from JSON, so it never reaches the row.

public class StringEnumField<TStringEnum> : StringField, IEnumTypeField
    where TStringEnum : StringEnum
parameter description
TStringEnum The string enumeration type.

Public Members

name description
StringEnumField(…) Initializes a new instance of the StringEnumField class.
EnumType { get; set; } Gets or sets the type of the string enumeration. It is TStringEnum by default, and no validation is performed when it is set to null, like Int32Field.EnumType.

Protected Members

name description
override ConvertJsonValue(…) Checks that the value read from JSON is one of the members of the string enumeration. An empty value is converted to null, like an empty string is for an enum field, so it is left to the required field validation.

Remarks

A value stored earlier that is no longer a member, e.g. a retired one, is rejected too when a row that has it is deserialized, as it is for numeric enums. Set EnumType to null to skip the validation.

See Also