I am using TextFieldParser
to parse a CSV file to import into a database using EntityFramework
.
TextFieldParser
returns each line of the CSV file as a string[]
. In order to save the objects, I need to build an object from each line. Is there any way to do this using AutoMapper
?
My object structure is like this:
public class Person
{
public string FirstName { get; set; }
public string MiddleName { get; set; }
public string LastName { get; set; }
public string Address { get; set; }
public string PhoneNumber { get; set; }
}
And my CSV lines are in the following format:
FirstName,MiddleName,LastName,Address,PhoneNumber