JoshClose / CsvHelper

Library to help reading and writing CSV files
http://joshclose.github.io/CsvHelper/
Other
4.76k stars 1.07k forks source link

Convert many different Classes #949

Closed HilmerChristophAkaHuima closed 6 years ago

HilmerChristophAkaHuima commented 6 years ago

In my project i want to convert many different classes to CSV. So I used your project but now I got a question because I want to use automapping and this do what it should do exept it comes to a array of other custom objects. Here stop the converter and only give the attributes back exept the array. I don't want to write a own mapper because i got 20 different classes and i can't change them because they come from a SDK. Can someone help me?

PS: sry for my bad english :)

 private void PrinterConsumablesUpdateSend(PrinterConsumableData data, string senddata)
        {
            try
            {
                using (var stringwriter = new StringWriter())
                {
                    using (var csv = new CsvWriter(stringwriter))
                    {
                        csv.Configuration.Delimiter = "|";

                        csv.WriteRecord(data);
                    }
                    LogClass.WriteErrorLog(stringwriter.ToString());
                }
            }
            catch (Exception ex)
            {
                LogClass.WriteErrorLog(ex);
            }
        }
JoshClose commented 6 years ago

Can you show the PrinterConsumableData class you're using?

HilmerChristophAkaHuima commented 6 years ago

I solved my problem myself but thank you for your help it was only a thinking problem :)