Is there some way to map a IList<>
property which does not have a set;
method?
Source Class:
public class SourceClass
{
private IList<string> strings;
public IList<string> Strings { get { return this.strings; } }
public SourceClass() { this.strings = new List<string>() { "s1", "s2", "s3" };
//...
}
Destionation Class:
public class DestinationClass
{
private IList<string> strings;
public IList<string> Strings { get { return this.strings; } }
public DestinationClass() { this.strings = new List<string>();
//...
}
As you can see, neither class has set;
implemented. The result is that when I perform AutoMapper.Mapper.Map<SourceClass, DestinationClass>(source, destination)
, the Strings
property is empty.
The obvious solution is to provide a set;
implementation is DestinationClass
, however, I would like to know how to provide a custom configuration in order to deal with these troubles.
Currently, my configuration is:
public class XProfile : AutoMapper.Profile
{
protected override void Configure()
{
AutoMapper.Mapper.CreateMap<SourceClass, DestinationClass>();
}
}