Skip to content

Write CSV with dynamic columns from F# #2348

@ntwilson

Description

@ntwilson

I'm trying to use CsvHelper to write a CSV file with dynamic columns from F#. The trouble is that F# doesn't have the dynamic keyword like C# does. You mentioned in 2017 in #709:

There is one weird issue though. It works with IEnumerable but gets that same exception for IEnumerable. I believe this is because it's only doing special logic when it's a dynamic type. Otherwise ExpandoObject is treated just like any other object, which wouldn't work well.

I believe that using an IEnumerable<dynamic> is the only way to write dynamic columns with CsvHelper, but this isn't how F# handles dynamic objects. In F#, to use dynamic objects, you still use the type ExpandoObject alongside the FSharp.Interop.Dynamic package. So it's impossible to create an IEnumerable<dynamic> - it would just be an IEnumerable<ExpandoObject>.

Is there any sort of workaround that I could use to create dynamic content without having to rely on IEnumerable<dynamic>?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions