var menuQuery = repository.MenuMasters.OrderBy(c => c.Position).Select(c => new { ID = c.MenuMasterID, Position = (MenuItemPosition)c.Position + " - " + c.SitePage.Title });
ViewBag.ParentID = new SelectList(menuQuery, "ID", "Position", selectedParentId);
public int Position { get; set; }
public MenuItemPosition MenuPosition {
get { return (MenuItemPosition)Position; }
set { Position = (int)value; }
}
public enum MenuItemPosition {
Top = 1, Main = 2, Footer = 3
}
I got an error which said "Unable to cast the type 'Type Name' to type 'Type Name'. LINQ to Entities only supports casting Entity Data Model primitive types."
MenuItemPosition is "Enum", Title is "string"
How can I fix this? Many thanks~!