GithubHelp home page GithubHelp logo

ConfigurationException: 'Types that inherit IEnumerable cannot be auto mapped' when using custom class based on DynamicObject (NOT ExpandoObject) which also implements IDictionary about csvhelper HOT 3 CLOSED

eduarddejong avatar eduarddejong commented on July 17, 2024
ConfigurationException: 'Types that inherit IEnumerable cannot be auto mapped' when using custom class based on DynamicObject (NOT ExpandoObject) which also implements IDictionary

from csvhelper.

Comments (3)

eduarddejong avatar eduarddejong commented on July 17, 2024

I already found the solution! :

Turns out it actually works without any problem. I needed to cast my object to dynamic in order to make it work with CsvWriter.

And this does not only apply to DynamicObject, but also to ExpandoObject.

I wasn't aware of this.

from csvhelper.

JoshClose avatar JoshClose commented on July 17, 2024

Were you using it as a dynamic object? Meaning

dynamic o = new ExpandoObject();

from csvhelper.

eduarddejong avatar eduarddejong commented on July 17, 2024

Oh, whoops. I see now that it's only picking up the dynamic properties of my DynamicObject implementation, and not the other properties. But it's not such a problem.
I can still create an ExpandoObject and copy all the properties, I have already written some code in that direction inside a LINQ Select construct.
I realize I probably already want to do that because I also have custom column names which I need as CSV header as well.

Were you using it as a dynamic object? Meaning

dynamic o = new ExpandoObject();

Thanks for your reply! I am actually doing as dynamic now in my Select and that also works, which works effectively the same (I do not add the dynamic properties using dot notation, I fill it dynamically like dictionary. That's why I also didn't need to use the dynamic keyword initially).

from csvhelper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.