I have this in my code:
@model Tuple<IEnumerable<dynamic>, IEnumerable<dynamic>, IEnumerable<dynamic>>
@(Html.Telerik().Grid(Model.Item3)
.Name("Grid")
.DataKeys(keys => keys.Add(c => c.Id))
)
And I get the error: An expression tree may not contain a dynamic operation.
Here is the controller code:
FirstClass firstC= new FirstClass ();
IEnumerable<dynamic> first= firstC.All();
SecondClass secondC= new SecondClass ();
IEnumerable<dynamic> second= secondC.All();
ThirdClass thirdc = new ThirdClass ();
IEnumerable<dynamic> third= thirdc .All();
Tuple<IEnumerable<dynamic>, IEnumerable<dynamic>, IEnumerable<dynamic>> result =
new Tuple<IEnumerable<dynamic>, IEnumerable<dynamic>, IEnumerable<dynamic>>(firstC, secondC, thirdc );
return View(result);
How to resolve this?
Best Answer
Expressions cannot be used with dynamic types. You will have to use strongly typed view models: