Automapper Type Converter from String to IEnumerable<String> is not being called
        Posted  
        
            by Anton
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Anton
        
        
        
        Published on 2010-04-01T13:41:56Z
        Indexed on 
            2010/04/02
            23:53 UTC
        
        
        Read the original article
        Hit count: 788
        
Here is my custom Type Converter.
public class StringListTypeConverter : TypeConverter<String, IEnumerable<String>>
{
    protected override IEnumerable<string> ConvertCore(String source)
    {
        if (source == null)
            yield break;
        foreach (var item in source.Split(','))
            yield return item.Trim();
    }
}
public class Source
{
    public String Some {get;set;}
}
public class Dest
{
    public IEnumerable<String> Some {get;set;}
}
// ... configuration
Mapper.CreateMap<String, IEnumerable<String>>().ConvertUsing<StringListTypeConverter>();
Mapper.CreateMap<Source, Dest>();
The problem: StringListTypeConverter is not being called at all. Dest.Some == null.
© Stack Overflow or respective owner