我有一個名爲PanContent指定的類型成員「狀態」不支持LINQ到實體
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不支持指定的類型成員'狀態'。 只有初始化,實體成員和實體導航屬性都支持。」
任何幫助感激地接受!
.net框架的版本和EntityFramework的版本是什麼? –