It is not feasible.. Say the target class has big object graph, Auto Mapper map whole graph but ignore a list of properties from parameter. If only copy should copy properties by reflection which contain child entities, the list would be long and code would be complex.
Say the SurveyDataMapper has default Map method that map every property, and then call this extension method, it's too late, since SurveyDataMapper already mapped the properties that should ignore.
where should put this line: PatchExtensions.PatchFromMapped(uploaded, surveyData, mapper.Map, requiredProperties)?
What about this converter: public class CurrencyObjectTypeConverter : ITypeConverter<double?, CurrencyObject[]?> { public CurrencyObject[]? Convert(double? source, CurrencyObject[]? destination, ResolutionContext context) { if (!source.HasValue) return null; var arr = new CurrencyObject[1] { new CurrencyObject { CurrencyValue = source.Value, Currency = "USD" } };
return arr;
}
}
Then it's hard code a lot of property names in above code, what about there 100 properties that should map? and this extension method is used by many classes' mapping.
When Migrate from Auto Mapper to Mapperly, we have current existing code: used in AutoMapper profile, how to migrate this code:
CreateMap<UploadedSurveyData, SurveyData>()
.IgnoreNotInListMembers (...);
public static class AutoMapperProfileExtension
{
public static IMappingExpression<TSource, TDestination> IgnoreNotInListMembers<TSource, TDestination>(this IMappingExpression<TSource, TDestination> expr, List<string> requiredProperties)
where TDestination : class
{
var destinationType = typeof(TDestination);
if (requiredProperties == null || requiredProperties.Count == 0)
{
return expr;
}
foreach (var property in from property in destinationType.GetProperties()
where !requiredProperties.Contains(property.Name)
select property)
{
expr.ForMember(property.Name, opt => opt.Ignore());
}
return expr;
}
}
thanks.
When I do ABP upgrade from 8 to 10 (Micro Service template), I noticed that in new ABP code template that created by ABP legacy Cli, in the yarp, it is "AccountAdmin": { "ClusterId": "AuthServer", "Match": { "Path": "/api/account-admin/{**catch-all}" } }, However in our existing code base (Ocelot), it is: { "ServiceKey": "Identity Service", "DownstreamPathTemplate": "/api/account-admin/{everything}", "DownstreamScheme": "https", "DownstreamHostAndPorts": [ { "Host": "localhost", "Port": 44388 } ], "UpstreamPathTemplate": "/api/account-admin/{everything}", "UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ] },
Since in this upgrade, we also ugrade Ocelot to Yarp, shall we change Yarp per ABP template? Is there any backend code changes need to in Auth Server?
thank you very much!