This question is locked. New answers and comments are not allowed.
Has anyone got the MVC Grid custom server binding to work with models created using EF 4.1 Code First? I've tried modifying the MVC Grid example from the demo site (http://demos.telerik.com/aspnet-mvc/razor/grid/customserverbinding), but I get a NullReferenceException. The View is the same as the demo. The controller is below:
[GridAction(GridName = "Grid")]public ActionResult CustomServerBinding(GridCommand command){ IEnumerable data = GetServerData(!IsEmptyCommand(command) ? command : new GridCommand()); return View(data);}private IEnumerable GetServerData(GridCommand command){ DataLoadOptions loadOptions = new DataLoadOptions(); loadOptions.LoadWith<Order>(o => o.Customer); var dataContext = new NorthwindDataContext(); // EF 4.1 CODE FIRST GENERATED MODELS DO NOT HAVE A LOADOPTIONS //{ // LoadOptions = loadOptions //}; IQueryable<Practice> data = dataContext.Order; //Apply filtering data = data.ApplyFiltering(command.FilterDescriptors); ViewData["total"] = data.Count(); //Apply sorting data = data.ApplySorting(command.GroupDescriptors, command.SortDescriptors); //Apply paging data = data.ApplyPaging(command.Page, command.PageSize); //Apply grouping if (command.GroupDescriptors.Any()) { return data.ApplyGrouping(command.GroupDescriptors); } return data.ToList();}private bool IsEmptyCommand(GridCommand command){ return command.PageSize == 0;}