C# dynamics don't work as expected across projects
In our dto that represents a table of contents node we added a property of type dynamic where all the content-type specific data would go. For example, for ordinances, the ordinance adoption date and direct url would go there.
This code works fine from within the project (dll) where the table of contents list is first created (`node.d` is the dynamic property)
`var ords = flatToc.Where(node => !node.d.hasChildren)`
However, from within our api controller, whose project includes a reference to our business objects project where the code above lives, that same exact line produces an error to the effect of "object does not have a hasChildren property". Totally caught me off guard.
I was hoping to use dynamics more often in our api but now I'm reconsidering and may just stick with typed dtos.
Update: a little googling and I found these helpful answers on stackoverflow:
http://stackoverflow.com/questions/7656630/accessing-properties-of-anonymous-dynamic-types-across-dll-boundaries-gives-runt
http://stackoverflow.com/questions/2993200/return-consume-dynamic-anonymous-type-across-assembly-boundaries?rq=1
We generally use ExpandoObjects but for some unknown reason we were using anonymous types in the scenerio above. So it's not a dynamic problem; it's an anonymous type problem. Good to know!













