c#自动映射ITypeConverter目标始终为空

c#自动映射ITypeConverter目标始终为空,c#,automapper,C#,Automapper,我的Automapper ITypeConverter有问题。我有两个对象ClientDto和Client,如下所示: public class ClientDto { // Other propertis... public List<string> Scopes { get; set; } } public class Client { // Other propertis... public List<ClientScope>

我的Automapper ITypeConverter有问题。我有两个对象ClientDto和Client,如下所示:

public class ClientDto
{
     // Other propertis...
     public List<string> Scopes { get; set; }
}

public class Client
{
     // Other propertis...
     public List<ClientScope> Scopes {get; set;}
}
public class ClientScope
{
     public int Id { get; set; }
     public string Scope { get;set; }
     .....
}
public class StringToScopesConvert : ITypeConverter<string, ClientScope>
{
    public ClientScope Convert(string source, ClientScope destination, ResolutionContext context)
    {
        if (source.Equals(destination.Scope))
            return destination;

        return new ClientScope
        {
            Scope = source
        };
    }
}
仅当字符串值与ClientScope对象中的作用域不同时,我才希望将作用域从ClietDto映射到客户端。 我已经编写了自定义类型转换器,如下所示:

public class ClientDto
{
     // Other propertis...
     public List<string> Scopes { get; set; }
}

public class Client
{
     // Other propertis...
     public List<ClientScope> Scopes {get; set;}
}
public class ClientScope
{
     public int Id { get; set; }
     public string Scope { get;set; }
     .....
}
public class StringToScopesConvert : ITypeConverter<string, ClientScope>
{
    public ClientScope Convert(string source, ClientScope destination, ResolutionContext context)
    {
        if (source.Equals(destination.Scope))
            return destination;

        return new ClientScope
        {
            Scope = source
        };
    }
}
它总是抛出异常,因为Convert方法中的目标对象为null。
我怎样才能解决这个问题?谢谢升级AutoMapper。已安装最新版本的AutoMapper。Vers 10.0.0当您传递给
Map
的目标对象必须为空时。我编辑了我的问题以获得更多澄清,请您重新检查。ThanksCheck AutoMapper.Collection或自己在
作用域
属性的自定义解析器中编写代码。