I am trying to create a custom type converter for AutoMapper and my issue is "Cannot implicitly convert type"
This is my converter code:
public class StatusConverter<TValue> : ITypeConverter<string, Wrapper<TValue>> where TValue : Status
{
public Wrapper<TValue> Convert(string source, Wrapper<TValue> destination, ResolutionContext context)
{
return Status.Create(source);
}
}
The error happens on line return Status.Create(source);, it says can't convert from Wrapper<Status> to Wrapper<TValue>.
I have uploaded all other classes related to this here: https://dotnetfiddle.net/iSr94S
But my question is:
Why am I getting this error? I have put a constraint in the method where TValue : Status, so TValue will be of type Status, why is it complaining about the type?
Thanks