Hi,
I've found this strange behaviour while mapping inherited classes with nested field.
If we define two simple destination:
class DestBase
{
public DestBase() { }
public string Object { get; set; }
}
class Dest : DestBase
{
public Dest() { }
}
and source class with nested object field
class Source
{
public SomeObject Object { get; set; }
public string ObjectStr { get; set; }
}
class SomeObject
{
public SomeObject() {}
}
then try to map and compile them
Mapper.Register<Source, DestBase>()
.Member(dest => dest.Object, src => src.ObjectStr)
.Include<Source, Dest>();
Mapper.Register<Source, Dest>();
Mapper.Compile();
we will catch exception No parameterless constructor defined for this object.
I think this caused by property Object name duplication while including rules:
- If we change string property name DestBase.Object to some other (not as object property Source.Object), all works fine.
- If we remove dest classes inheritance, all works fine.
- And also if we duplicate registration in parent and child class, all works fine.
Mapper.Register<Source, DestBase>()
.Member(dest => dest.Object, src => src.ObjectStr)
.Include<Source, Dest>();
Mapper.Register<Source, Dest>()
.Member(dest => dest.Object, src => src.ObjectStr);
Mapper.Compile();
Is it normal? Should I duplicate member registration for all children?
Hi,
I've found this strange behaviour while mapping inherited classes with nested field.
If we define two simple destination:
and source class with nested object field
then try to map and compile them
we will catch exception No parameterless constructor defined for this object.
I think this caused by property Object name duplication while including rules:
Is it normal? Should I duplicate member registration for all children?