I have spent the past 2 days wondering why this is not working, but for my other tables it is working perfectly fine. I even tested my other model which contains many fields. BUt this particular one, even with ONLY 2 fields is not working. I know I might missing an obvious part, please help.
Here's my Model
public class ReceivedItem
{
public int ReceivedItemID { get; set; }
public int ItemID { get; set; }
}
ViewModel
public class ReceivedItemViewModel
{
public int ReceivedItemID { get; set; }
public int ItemID { get; set; }
}
Controller
[GridAction]
public ActionResult GetReceivedItems()
{
return View(new GridModel(GetReceivedItemsViewModels()));
}
private IQueryable<ReceivedItemViewModel> GetReceivedItemsViewModels()
{
return db.ReceivedItems
.Select(
c => new ReceivedItemViewModel
{
ItemID = c.ItemID
});
}
View
@(Html.Telerik().Grid<ReceivedItem>()
.Name("grdItems")
.DataBinding(binding => binding.Ajax()
.Select("GetReceivedItems", "Receiving"))
.DataKeys(keys => keys.Add(o => o.ItemID))
.Columns(cols =>
{
cols.Bound(c => c.ItemID);
})
.Pageable()
.Sortable()
.Groupable()
.Filterable()
)
Error i got using firebug:
The specified type member 'ReceivedItemID' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.
Where( a => a.Parent == parentObject)
. (Should beWhere( a => a.ParentId == parentId)
).