I have an ASP.NET MVC app. I am using the ExpandoObject
in my app. Currently, I have the following block in my .cshtml file:
foreach (System.Dynamic.ExpandoObject expo in ViewBag.ExpandoObjects)
{
<div>@filter.GetType().FullName</div>
}
This code works fine. In fact, it prints out System.Dynamic.ExpandoObject
onto the screen like I'd expect. However, when I update the code to the following, I get an error.
foreach (System.Dynamic.ExpandoObject expo in ViewBag.ExpandoObjects)
{
foreach (var key in expo.Keys)
{
<div>@key</div>
}
}
The error says:
CS1061: 'System.Dynamic.ExpandoObject' does not contain a definition for 'Keys' and no extension method 'Keys' accepting a first argument of type 'System.Dynamic.ExpandoObject' could be found (are you missing a using directive or an assembly reference?)
I do not understand why I'm getting this error. According to the documentation, there is a Keys property. What am I missing?