public enum AlertSeverity { Warning, Critical } public static class AlertSeverityExtensions { public static string ToDbString(this AlertSeverity s) => s switch { AlertSeverity.Warning => "WARNING", AlertSeverity.Critical => "CRITICAL", _ => throw new ArgumentOutOfRangeException(nameof(s)) }; public static AlertSeverity FromDbString(string v) => v switch { "WARNING" => AlertSeverity.Warning, "CRITICAL" => AlertSeverity.Critical, _ => throw new ArgumentOutOfRangeException(nameof(v), $"Unknown alert severity: '{v}'") }; }