Mapping of nested objects via column index
Hello, is it possible to map to objects containing nested objects when performing the mapping via column index?
public class EroeffnungbilanzWert
{
public string Kontonummer { get; set; }
public WertDaten Wertdaten { get; set; } = new();
}
public class WertDaten
{
public string Wert { get; set; }
public string Soll { get; set; }
public string Haben { get; set; }
}
By using this code the mapped values are not set to the nested object, but it runs without exception:
var excelMapper = new ExcelMapper(stream)
{
HeaderRow = true,
MinRowNumber = 2,
SkipBlankCells = false
};
excelMapper.AddMapping<EroeffnungbilanzWert>(5, s => s.Wertdaten.Soll);
This code results in an exception: var excelMapper = new ExcelMapper(stream) { HeaderRow = false, MinRowNumber = 2, SkipBlankCells = false }; excelMapper.AddMapping<EroeffnungbilanzWert>(4, s => s.Wertdaten.Soll);
But this code (not using nested object) works like expected: var excelMapper = new ExcelMapper(stream) { HeaderRow = false, MinRowNumber = 2, SkipBlankCells = false }; excelMapper.AddMapping<EroeffnungbilanzWert>(1, s => s.Kontonummer);
This should be possible, see here for an example: https://github.com/mganss/ExcelMapper/blob/10a751f40ef0ad48732bf6995556b31b6aab680d/ExcelMapper.Tests/Tests.cs#L2437