public static IMappingExpression <TSource, TDest> IgnoreAllUnmappedComplexTypes <TSource, TDest>(this IMappingExpression <TSource, TDest> expression) { var destType = typeof(TDest); var sourceType = typeof(TSource); expression.ForAllOtherMembers( delegate(IMemberConfigurationExpression <TSource, TDest, object> configurationExpression) { var propName = configurationExpression.DestinationMember.Name; var sourceProp = sourceType.GetProperties().Any(x => x.Name.EqualsIgnoreCase(propName)); if (sourceProp) { return; } var propType = destType.GetProperties().First(x => x.Name.EqualsIgnoreCase(propName)).PropertyType; if (!propType.IsValueType && !propType.IsEnum && propType != typeof(string) && propType != typeof(char[])) { configurationExpression.Ignore(); } }); return(expression); }
public static IMappingExpression <TSource, TDestination> IgnoreNullValues <TSource, TDestination>( this IMappingExpression <TSource, TDestination> mapperExpression) { mapperExpression.ForAllOtherMembers(source => { source.Condition((s, d, sourceValue, destValue, rc) => { return(sourceValue != null); }); }); return(mapperExpression); }
/// <summary> /// Ignore all source members not previously configured which have a null value. /// </summary> public static void IgnoreAllOtherNullMembers <TSource, TDestination>(this IMappingExpression <TSource, TDestination> mappingExpression) => mappingExpression.ForAllOtherMembers(a => a.MapFrom <IgnoreNullSourceValues <TSource, TDestination>, object>(a.DestinationMember.Name));
public static IMappingExpression <TSource, TDest> IgnoreOther <TSource, TDest>(this IMappingExpression <TSource, TDest> expression) { expression.ForAllOtherMembers(opt => opt.Ignore()); return(expression); }
/// <summary> /// Alternate syntax for ".ForAllOtherMembers(dest => dest.Ignore()); /// Instead of: /// <![CDATA[ /// .ForAllOtherMembers(dest => dest.Ignore()); /// ]]> /// ...you can code: /// <![CDATA[ /// .IgnoringAllOtherMembers() /// ]]> /// </summary> /// <typeparam name="TSource">Source ("map from") type.</typeparam> /// <typeparam name="TDestination">Destination ("map to") type.</typeparam> /// <param name="mappingExpression"> /// AutoMapper <see cref="IMappingExpression{TSource, TDestination}"/> instance. /// </param> public static void IgnoreAllOtherMembers <TSource, TDestination>( this IMappingExpression <TSource, TDestination> mappingExpression) { mappingExpression.ForAllOtherMembers(dest => dest.Ignore()); }
public static void IgnoreAllOtherMembers(this IMappingExpression map) => map.ForAllOtherMembers(o => o.Ignore());
public static void IgnoreAllOtherMembers <TSource, TDestination>( this IMappingExpression <TSource, TDestination> map) => map.ForAllOtherMembers(o => o.Ignore());
public static IMappingExpression <TSource, TDest> IgnoreOther <TSource, TDest>(this IMappingExpression <TSource, TDest> mapperExpression) { mapperExpression.ForAllOtherMembers(u => u.Ignore()); return(mapperExpression); }