Automapper 忽略 属性 泛型映射

Automapper ignore property on generics mapping

这个通用方法工作正常:

public static U PropertyAutomapper<T, U>(T source)
    where T : class, new()
    where U : class, new()
{
    Mapper.CreateMap(typeof(T), typeof(U));
    return Mapper.Map<T, U>(source);
}

我有这个界面:

public interface IPassword
{
    string Password { get; set; }
}

我想忽略这个 属性 ('Password')但是我没有 'ignore' in the intelissense

public static U PropertyAutomapperNoPassword<T, U>(T source)
    where T : IPassword
    where U : IPassword
{
    Mapper.CreateMap(typeof(T), typeof(U))...   
    return Mapper.Map<T, U>(source);
}

有什么想法吗?

谢谢,

试试这个:

Mapper.CreateMap<T, U>()
    .ForMember(dest => dest.Password, opt => opt.Ignore())