【发布时间】:2023-04-11 10:40:01
【问题描述】:
如何在 Visual C# ASP .NET MVC 4 Web 应用程序中使用枚举?
我有一个 mySQL 数据库,其中包含一个表“flight”,其中包含一个使用该类型的字段“flightDay” enum('星期一', '星期二', '星期三', '星期四', utf8_bin
如何使表 Flight 的类编译/工作?在我的应用程序的模型文件中。
[Table("flight")]
public class Flight
{
[Key, Column(Order = 1)]
public int id { get; set; }
public int route { get; set; }
public enum flightDay { get; set; } **// How to make this work?**
public int aircraft { get; set; }
}
【问题讨论】:
-
当你从数据库中检索它时,你必须将它从字符串转换为枚举类型
-
@Dan Hunex 请你解释一下怎么做?