Reputation: 478
Compiler Error Message: CS1977: Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type
I am using the Respository pattern in this project, so the data i retrieved by way of service calls and not regular linq queries. I am unsure as to what they may mean by cast the arguement to a delegate or exp. tree type. here is the code.
@(Html.Telerik().Grid(Model)
.Name("Grid").Columns(columns =>
{
columns.Bound(o => o.formId).Width(100);
columns.Bound(o => o.Name).Width(200);
//columns.Bound(o => o.ShipAddress);
//columns.Bound(o => o.OrderDate).Format("{0:MM/dd/yyyy}").Width(120);
})
.DataBinding(dataBinding =>
{
dataBinding.Server().Select("Index", "Grid", new { ajax = ViewData["ajax"] });
dataBinding.Ajax().Select("_Index", "Grid").Enabled((bool)ViewData["ajax"]);
})
.Scrollable(scrolling => scrolling.Enabled((bool)ViewData["scrolling"]))
.Sortable(sorting => sorting.Enabled((bool)ViewData["sorting"]))
.Pageable(paging => paging.Enabled((bool)ViewData["paging"]))
.Filterable(filtering => filtering.Enabled((bool)ViewData["filtering"]))
.Groupable(grouping => grouping.Enabled((bool)ViewData["grouping"]))
.Footer((bool)ViewData["showFooter"])
)
public ActionResult Index(bool? ajax, bool? scrolling, bool? paging, bool? filtering, bool? sorting,
bool? grouping, bool? showFooter)
{
ViewData["ajax"] = ajax ?? true;
ViewData["scrolling"] = scrolling ?? true;
ViewData["paging"] = paging ?? true;
ViewData["filtering"] = filtering ?? true;
ViewData["grouping"] = grouping ?? true;
ViewData["sorting"] = sorting ?? true;
ViewData["showFooter"] = showFooter ?? true;
return View(formService.GetForms());
}
[GridAction]
public ActionResult _Index()
{
return View(new GridModel(formService.GetForms()));
}
Upvotes: 0
Views: 1843
Reputation: 478
It was negligence on my part, the return type of the view was of the type of the Viewmodel as opposed to the model coming in from the service model.
Upvotes: 2
Reputation: 30661
There is something dynamic in your model, isn't it. The error is telling that C# can't create an expression from a dynamically dispatched operation.
If you want to bind Telerik Grid for ASP.NET MVC to dynamic model check this code library project.
Upvotes: 0