With CsvHelper, how do I make it use string.Empty instead of Null for missing varchar fields?
Say I have a c# class “Person” with a property named “FirstName”. In the database, FirstName is a VARCHAR(100) NOT NULL field. When CsvHelper imports a CSV that lacks a FirstName field, I need it to use a default value of string.Empty for that field rather than Null. I don’t want to create a custom Map for each record type because I have many of those, so how can I configure CsvHelper to automatically use string.Empty instead of Null when it encounters a missing varchar field on any record type it encounters?
Can the CsvHelper library be configured to parse records that have an extra pair of outer quote marks surrounding each record?
I have some CSV files coming in from an external system. Each record (not the header) is surrounded by an outer pair of double quotes. I haven’t seen CSV files like this before, so I’m not even sure if this is a standard format or not. Here’s a simulated example: