【发布时间】:2016-02-28 11:13:33
【问题描述】:
我正在使用 Entity Framework 构建模型并购买了响应式 CSS。
内置的固定图标带有 CSS。如下(Name and Icon Class Value)
我需要一种方法将图标名称保持为固定枚举,以便从VS intellisense 访问它。目前我们不能在实体框架中存储为实体表(因为它需要与难以维护的表的关系)并且枚举不允许字符串类型。
无效的代码:
public sealed class IconType
{
public static readonly IconType Rupee_Icon = new IconType("rupee-icons");
public static readonly IconType Doller_Icon = new IconType("doller-icon");
private IconType(int EnumID,string EnumObjectValue)
{
IconValue = EnumObjectValue;
}
public string IconValue { get; private set; }
}
更多无效代码(CSS 类名包含空格,如ui bell icon):
public enum Icon
{
NotSet=0,
Idea Icon=1,
Bell Icon =2
}
还有其他方法可以在 EF 中使用名称/对象作为枚举或常量,以便在 Visual Studio 中轻松进行智能感知吗?
【问题讨论】:
标签: c# entity-framework enums icons constants