This project has moved. For the latest updates, please go here.

ExpandoObject as IEnumerable?

Apr 18, 2011 at 9:16 PM

Hello, first, thanks for this great tool.

Second, I'm wondering if you've tried this with an IEnumerable<ExpandoObject> before? My first pass didn't work, and I'm trying some other things now. It's having a hard time deciphering dynamics, I think..

Apr 18, 2011 at 9:26 PM

Hi Tim,

Can you paste some example code and how you are using it? It probably won't work out of the box with ExpandoObject but it should be pretty easy to create a custom IReportSource for ExpandoObject. If you paste some sample code and usage I can take a quick stab at it.


Apr 18, 2011 at 10:28 PM

Hi Matt, basically, I'm doing:


List<ExpandoObject> all = new List<ExpandoObject>();
var d = new ExpandoObject();
var _student = d as IDictionary<stringobject>;
_student.Add("DistrictNumber", s.DistrictNumber);
_student.Add("SchoolId", s.Schools[0].SchoolId);
_student.Add("FullName", s.FullName);

Report r = new Report(all.ToReportSource());
the call to the report writer.write method fails and there are no DataFieldItems (?) on the report object (sorry ,cannot remember the exact name)

Hope this helps...thanks!

Dec 2, 2011 at 5:03 PM
Edited Dec 2, 2011 at 5:04 PM

Hi Tim,

Sorry this took so long to update :)

I've added Dynamic/ExpandoObject support in the latest source code. Since I want to support .NET 3.5 still I have chosen to add it a source code file that developers can drop into their project if they need. The Nuget package to get this file will be called DoddleReport.Dynamic - it will be added to NuGet tonight.

BTW here is the sample code to use it - but you need the DynamicReportSource.cs file added to your project before this will work!

   public ReportResult Expando()
            var all = new List<ExpandoObject>();
            dynamic d = new ExpandoObject();
            d.DistrictNumber = 1566;
            d.SchoolId = 1;
            d.FullName = "Matt Hidinger";

            dynamic d2 = new ExpandoObject();
            d2.DistrictNumber = 13566;
            d2.SchoolId = 1;
            d2.FullName = "Bob Jones";


            var report = new Report(all.ToReportSource());

            // Customize the Text Fields
            report.TextFields.Title = "Expando Report";
            report.TextFields.SubTitle = "This is a sample report showing how Doddle Report works";
            report.TextFields.Footer = "Copyright 2011 &copy; The Doddle Project";
            report.TextFields.Header = string.Format(@"Report Generated: {0}", DateTime.Now);

            report.DataFields["SchoolId"].HeaderText = "School";

            // Render hints allow you to pass additional hints to the reports as they are being rendered
            report.RenderHints.BooleanCheckboxes = true;

            return new ReportResult(report);