استفاده از Auto-ignore در AutoMapper
نویسنده: سالار ربال
تاریخ: ۱۳۹۴/۰۲/۱۱ ۱۴:۴۹
آدرس: www.dntips.ir
| مطالب | ۳۶۹۴ |
| نویسندگان | ۲۷۶ |
| گروههای مطالب | ۱۰۲۴ |
| نقشههای راه | ۱۱۹ |
| دورهها | ۱۴ |
| اشتراکها | ۱۷۹۱۴ |
public static IMappingExpression<TSource, TDestination> IgnoreAllNonExisting<TSource, TDestination>(this IMappingExpression<TSource, TDestination> expression)
{
foreach (var property in expression.TypeMap.GetUnmappedPropertyNames())
{
expression.ForMember(property, a => a.Ignore());
}
return expression;
} public class UserProfile : Profile
{
protected override void Configure()
{
CreateMap<RegisterViewModel, ApplicationUser>()
.IgnoreAllNonExisting();
}
public override string ProfileName
{
get { return this.GetType().Name; }
}
}