-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Description
Hello!
I'm mapping my CSV records to a concrete object and I was wondering if there's a way to persist the row number in the concrete object?
I have a mapped object that looks like this:
public class CsvRowDto {
public string FirstName {get; set;}
public string LastName {get; set;}
}
And I'm trying to achieve something like this:
public class CsvRowDto {
public int RowNumber {get; set;}
public string FirstName {get; set;}
public string LastName {get; set;}
}
The use case for this is to provide better error reporting. When my application detects a validation/business rule error I'd like to report the row number that had an error.
var records = csvReader.GetRecords<CsvRowDto>().ToList();
foreach(var person in records) {
if(string.IsNullOrEmpty(person.FirstName)) {
Console.WriteLine("First name is invalid: " + person.RowNumber);
}
}
dandry, S1r-Lanzelot and vlflorian
Metadata
Metadata
Assignees
Labels
No labels