Reputation: 954
I'm using the latest version of AutoMapper (13.0.1) and want to map from an Interface to aconcrete object, but I get an exception from AutoMapper (unmapped members (Name, Value) were found.).
If I add a setter in the interface definition (IGroup) for the properties (Name and Value) it works, but it should not be necessary to have a setter for members of the source object.
Any help would highly be appreciated.
EDIT The problem is configuration.AssertConfigurationIsValid(); --> this throws the exception, however if I remove the configuration.AssertConfigurationIsValid(); everything works fine, so the mapping does work without any problems but the AssertConfigurationIsValid seems to not work correctly.
Please have a look at the sample below.
public interface IGroup
{
string Name
{
get;
//set; //it works with the setter
}
string Value
{
get;
//set; //it works with the setter
}
}
public class Group : IGroup
{
public string Name
{
get;
set;
}
public string Value
{
get;
set;
}
}
public class GroupEF
{
public string Name
{
get;
set;
}
public string Value
{
get;
set;
}
}
CreateMap<Group, GroupEF>();
CreateMap<IGroup, GroupEF>()
.Include<Group, GroupEF>(); //it doesn't matter if I add Include<> or not.
Upvotes: 0
Views: 180
Reputation: 954
The problem was in our BasePeofile where we set ShouldMapProperty to a wrong value, which caused this problem.
Thx for your help!
Upvotes: 0