I have a class called 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; }
}
And I have an enum type PanContentStatus
public enum PanContentStatus
{
Active = 0,
Partial,
Inactive,
Deleted
}
I'm trying to use this in my Controller
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();
}
}
and then use it in my 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>
but I'm getting the error "The specified type member 'Status' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported."
Any help gratefully received!