我有一个名为 PanContent 的课程
public class PanContent
{
public int Id { get; set; }
public string Description { get; set; }
public string Content { get; set; }
public PanContentStatus Status { get; set; }
public ActivityId ActivityId { get; set; }
}
我有一个枚举类型 PanContentStatus
public enum PanContentStatus
{
Active = 0,
Partial,
Inactive,
Deleted
}
我正在尝试在我的控制器中使用它
public ActionResult Index()
{
var db = new TlDbContext();
var status = PanContentStatus.Partial;
var content = db.PanContents.Where(p => p.Status == status).FirstOrDefault();
if (content != null)
{
return View(content);
}
else
{
return View();
}
}
然后在我看来使用它
@model IEnumerable<Sample.Models.PanContent>
<script type="text/javascript">
var model = @Html.Raw(Json.Encode(Model));
for (var m in model) {
console.log(m.Content);
}
</script>
但我收到错误“LINQ to Entities 不支持指定的类型成员'状态'。仅支持初始化程序、实体成员和实体导航属性。”
任何帮助都感激不尽!