I have a collection Car including fields for date of production, car name, production place - this is a new model named ProductionPlace including City, Address and Id, and there is another collection in Cars which is Creator - including name, surname and country.
So this basically looks like this
Cars
{
ProductionDate,
Name,
ProductionPlace
{
Id,
City,
Address
},
Creator
{
Name,
Surname,
Country
}
How can I map those using CSV Helper? I'm getting "there is no field named Creator" for example. I can simply map fields but not collection nested in my main collection
Edit
My code as far looks like that
public void MapCar()
{
Map(mapping => mapping.Car).ConvertUsing(
row => { List<Car> car = new List<Car>
{
ProductionDate = row.GetField("ProductionDate"),
Name = row.GetField("Name"),
ProductionPlace = new ProductionPlace
{
Id = row.GetField("Id"),
City = row.GetField("City"),
Address = row.GetField("Address")
},
Creator = new Creator
{
Name = row.GetField("Name"),
Surname = row.GetField("Surname"),
Country = row.GetFiele("Country")
}
};)}
Both Creator and ProductionPlace are separate models. And Car is a model using those two as it's fields.