Initialize DTO properties with default value or null. #123
-
Hi!!! I have few requirements to minimize the errors while reader CSV and Excel from an IFormFile. The goal is to automatically fix bad data and assign DTO property default value when the parsing failed. I would like to know how to initialize DTO properties to a default value (null, date now, enum, etc.) depending on data type and/or [DefaultValue] attribute. I also need to be able to get all the failed parsed columns. Currently it seems to stop processing the columns when the first column failed to parse. How can I initialize DTO properties if parsing failed and also get all the failed columns for each row?
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
I'm not sure what you mean by this. What part of the process is failing? |
Beta Was this translation helpful? Give feedback.
-
My goal is to provide user hint about bad formatted excel file and what type of conversion failed with no repetition validation of each type. Since I'm not able to evaluate each cell and provide my own local validation without throwing exception that's make the code poorly perform, I had to loop the It works well until I wanted to evaluate if a cell contains bad formula (#N/A, #NAME, etc.). I cannot find a way to get the excel cell raw value because the I would like to be able to use the following method:
Please can you tell me how can I get the excel cell raw value just like the CsvDbDataReader. For now I will use a converter from
Thanks! |
Beta Was this translation helpful? Give feedback.
-
Thanks!!! I found the
|
Beta Was this translation helpful? Give feedback.
Thanks!!! I found the
GetExcelDataType
in your source code so I did exactly what you suggested: