### Question:

Given to object `FooBar` that contains a List of `Bar`, with `FooBar` and `Bar` define as such:

```
class FooBar{
    int FooID {get;set;}
    string FooProperty1 {get;set;}
    List<Bar> Bars {get;set;};
}

class Bar{
    int BarID {get;set;}    
    string BarProperty1 {get;set;}  
    string BarProperty2 {get;set;}  
    string BarProperty3 {get;set;}
}

```

I get the following CSV as input:

```
1,FooProperty1,BarID_1,BarProperty1_1,BarProperty2_1,BarProperty3_1,BarID_2,BarProperty1_2,BarProperty2_2,BarProperty3_2

```

Where the field BarID, BarProperty1, BarProperty2, BarProperty3 are suffixed by their indice in the collection.

How do I deserialise this input into my object? 

[![enter image description here](https://i.stack.imgur.com/ebTuJ.png)](https://i.stack.imgur.com/ebTuJ.png)

---

### input Exemple:

1 instance of FooBar, and 2 sub Bar: `1,FooProperty1,BarID_1,BarProperty1_1,BarProperty2_1,BarProperty3_1,BarID_2,BarProperty1_2,BarProperty2_2,BarProperty3_2` 

1 instance of FooBar but no Bar:  

`1,FooProperty1`

---

### Tries:

I have try using Convert in order to map those property to a new instance of Bar like :

```
public class FooBarMap : ClassMap<FooBar> 
{
    public FooBarMap()
    {
        Map(m => m.FooID);
        Map(m => m.Bars).ConvertUsing(row =>
        {            
            var list = new List<Bar>
            {
                new Bar { 
                    BarProperty1 = row.GetField("BarProperty1_1"), 
                    BarProperty2 = row.GetField("BarProperty2_1"),
                    // .. Other Properties
                },
                new Bar {}, //.. Same on _2
            };
            return list;
        });
    }
}

```

Of course no control over the input. I would have been sending Json/Xml not CSV.