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())