Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/316.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 泛型映射上的Automapper ignore属性_C#_.net_Automapper - Fatal编程技术网

C# 泛型映射上的Automapper ignore属性

C# 泛型映射上的Automapper ignore属性,c#,.net,automapper,C#,.net,Automapper,这种通用方法效果很好: 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); } 我想忽略此属性(“Password”),但我没有intelissens

这种通用方法效果很好:

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);
}
我想忽略此属性(“
Password
”),但我没有intelissense中的“ignore”

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);
}
公共静态U属性自动映射PernoPassword(T源)
其中T:IPassword
其中U:IPassword
{
CreateMap(typeof(T),typeof(U))。。。
返回Mapper.Map(源);
}
有什么想法吗

谢谢,

试试这个:

Mapper.CreateMap<T, U>()
    .ForMember(dest => dest.Password, opt => opt.Ignore())
Mapper.CreateMap()
.FormMember(dest=>dest.Password,opt=>opt.Ignore())
试试这个:

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