The Simple Answer to the WebGrid sorting issue - LINQ to Entities only supports casting EDM primitive or enumeration types

Spent so much time on this error, examining my models, data structure etc. What it boiled down to was the sortability of the IEnumerable object on the page vs a sortable list. All you need to do most of the time is to recast it in your controller like this:

 var retdata = bl.GetPidHistory(pid);
 var itemstoreturn = retdata.ToList();
 return View(itemstoreturn);

 This is applicable when your view has a model like this: @model IEnumerable

Comments

Popular posts from this blog

Linq Exclude from separate list

Sorting Ascending and Descending

Linq Query Syntax vs Method Syntax