예제 #1
0
 /// <summary>
 /// Extension to ignore a path back to the source class in the reverse map
 /// </summary>
 // ReSharper disable once UnusedMember.Global
 public static IMappingExpression <TSource, TDestination> IgnorePath <TSource, TDestination>(
     this IMappingExpression <TSource, TDestination> map,
     Expression <Func <TDestination, object> > selector)
 {
     map.ForPath(selector, config => config.Ignore());
     return(map);
 }
예제 #2
0
 public static IMappingExpression <ServiceOrderAirFreight, TDestination> MapBase <TDestination>(
     this IMappingExpression <ServiceOrderAirFreight, TDestination> mapping)
     where TDestination : ServiceOrderBaseResponse
 {
     // all base class mappings goes here
     return(mapping.ForPath(d => d.VendorId, opt => opt.MapFrom(src => src.CarrierVendor.Id))
            .ForPath(d => d.VendorName, opt => opt.MapFrom(src => src.ServiceOrder.Vendor.Name))
            .ForPath(d => d.CarrierVendorName, opt => opt.MapFrom(src => src.CarrierVendor.Name))
            .ForPath(d => d.QuoteReferenceNumber, opt => opt.MapFrom(src => src.ServiceOrder.QuoteReferenceNumber)));
 }
예제 #3
0
        public static IMappingExpression <TSource, TDestination> MapForPath <TSource, TDestination, TResult, TDestinationMember>(
            this IMappingExpression <TSource, TDestination> mappingExpression,
            Expression <Func <TDestination, TDestinationMember> > destinationMember,
            Expression <Func <TSource, TResult> > sourceMember)
        {
            if (destinationMember.Body is MemberExpression)
            {
                mappingExpression.ForPath(destinationMember, src => src.MapFrom(sourceMember));
            }

            return(mappingExpression);
        }
예제 #4
0
        private static void MapAuditMembers <TEntity, TDto>(
            IMappingExpression <TDto, TEntity> reverseEntityMap)
        {
            if (typeof(IMultiTenant).IsAssignableFrom(typeof(TEntity)))
            {
                reverseEntityMap.ForPath <TDto, TEntity, Guid?>("TenantId", map => map.Ignore());
            }

            if (typeof(IMayHaveCreator).IsAssignableFrom(typeof(TEntity)))
            {
                reverseEntityMap.ForPath <TDto, TEntity, Guid?>("CreatorId", map => map.Ignore());
            }

            if (typeof(IMustHaveCreator).IsAssignableFrom(typeof(TEntity)))
            {
                reverseEntityMap.ForPath <TDto, TEntity, Guid>("CreatorId", map => map.Ignore());
            }

            if (typeof(IHasCreationTime).IsAssignableFrom(typeof(TEntity)))
            {
                reverseEntityMap.ForPath <TDto, TEntity, DateTime>("CreationTime", map => map.Ignore());
            }

            if (typeof(IModificationAudited).IsAssignableFrom(typeof(TEntity)))
            {
                reverseEntityMap.ForPath <TDto, TEntity, DateTime?>("LastModificationTime", map => map.Ignore());
                reverseEntityMap.ForPath <TDto, TEntity, Guid?>("LastModifierId", map => map.Ignore());
            }
        }
예제 #5
0
 public static IMappingExpression <TSource, TDestination> ForPath <TSource, TDestination, TMember>(this IMappingExpression <TSource, TDestination> mapping, string memberName, Action <IPathConfigurationExpression <TSource, TDestination, TMember> > memberOptions)
 {
     return(mapping.ForPath(ExpressionHelper.GetPropertyExpression <TDestination, TMember>(memberName), memberOptions));
 }