I have a Business Object class containing private fields which are populated in the constructor
private int mP_Id;
private int mP_MerchantId;
private int mP_ProductId;
private decimal mP_Price;
private int mP_StockCount;
private string mP_Condition;
private bool mP_Published;
private int? mP_ConditionId;
private string mP_URL;
private string mP_CurrencyCode;
private DateTime? mP_DateUpdated;
private bool mP_Active;
private string mP_MerchantProductIdentifier;
private int? mP_ApiProductFoundId;
I have a CSV file that contains these columns but also has additional columns that will be used in the business logic to retrieve the correct mP_ProductId from another database table.
If I use CsvContext.Read<T>()
it throws an exception telling me that the extra columns are not found in my Business Object.
var cc = new CsvContext();
var relationships = cc.Read<MerchantProductRelBO>(file.FilePath, inputFileDescription);
I tried to place these extra fields and overload the constructor in the MerchantProductRelBO.custom.cs but it still didn't use the overloaded constructor and threw the same exception. I can't do this in the MerchantProductRelBO.cs because the file gets overwritten anytime the database structure changes.
Do I just need to abandon the LinqToCsv library and write a manual parser to read from the CSV or is there a way to get it to parse the extra-BO columns without throwing an exception?