I'm using Rob Conery's Massive ORM, and I haven't been able to bind the resulting ExpandoObject
to a GridView
.
I did find another Stackoverflow question that suggests using a framework called impromptu, but I'm not sure if that would work for this. If you know it does, please provide a code sample to actually convert an ExpandoObject
to something that the GridView
control can bind to.
Worst case scenario, has anyone implemented an additional method (that can be shared) for Massive to convert the resulting ExpandoObject
to a POCO?
any help is greatly appreciated. Thanks.
If we are talking GridView (meaning not WPF) then impromptu can proxy an expando to a poco given an interface. Say we have a list of expando's you can convert them to poco's:
I adapted Brian's accepted answer to be a little more concise and LINQ-y:
(This assumes you've defined an IEnumerable.Each extension, which every codebase I've worked on has had).
Since you can't bind to an ExpandoObject, you can convert the data into a DataTable. This extension method will do that for you. I might submit this for inclusion to Massive.
adapting from Ben's answer
I came to this thread after researching on the same topic, I found no solution but constructed my own as I desperately needed this one. So here is my solution without going POCO that really works.
And simply bind this table to your grid!
I tested it and it worked for me.
Ok, apparently as of now, you just can't bind a GridView control to an ExpandoObject instance. I had to use reflection to convert the ExpandoObject to a POCO class.