I have two complex objects each has a list in them. I am using AutoMapper to map them together, for example:
ConfigurationStore
.CreateMap<IProcessDefinition, ProcessDefinition>()
.ForMember(p => p.ProcessDefinitionDomainId, opt => opt.MapFrom(t => t.DomainId))
.ForMember(p => p.Schemas, opt => opt.MapFrom(t => t.Schemas))
.ForMember(p => p.ConfigurationValues, opt => opt.MapFrom(t => t.Configs))
.ForMember(p => p.Libraries, opt => opt.MapFrom(t => t.Libraries));
In the given example t.Schemas
is a list of implementation of ISchemas
which is a class with name and value members, both are of type string
. On the other hand, p.Schemas
is just a list of strings. I have tried resolver approach for so, described here Using AutoMapper to map the property of an object to a string.
It fails because resolver only works with root objects. I have also tried registering a custom between both the schemas, which didn't work either.
t.Schemas = List<string>
p.Schemas = List<ISchema>
public interface ISchema
{
string name;
string class;
}
Please let me know if you have any advice for me, much appreciate it.