❔ How to force enumaration on ExpandoObj?

Hey guys, i encountered a situation where i have this ExpandoObj I need to enumerate its properties (so it doesnt deffer execution on some event i have) Problem is, nothing seems to work. tried using like aka :
objectlist.Select(x=>{return x}).ToArray()
objectlist.Select(x=>{return x}).ToArray()
In addition tried going over the expandoobj with
foreach (var obj in objectList.OfType<ExpandoObject>())
{
var dictionaryView = obj as IDictionary<string, object>;
foreach (var key in dictionaryView.Keys.ToList()) // .ToList() is crucial to avoid collection modification issues.
{
var value = dictionaryView[key];
}
}
foreach (var obj in objectList.OfType<ExpandoObject>())
{
var dictionaryView = obj as IDictionary<string, object>;
foreach (var key in dictionaryView.Keys.ToList()) // .ToList() is crucial to avoid collection modification issues.
{
var value = dictionaryView[key];
}
}
And still when I hover over the objectList i get a "result view" and "dynamicview" which means it hasnt been enumarated.
2 Replies
antimatter8189
antimatter8189OP17mo ago
Had to resort to create a class at runtime with reflection emit, no way around this?
Accord
Accord17mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.

Did you find this page helpful?