Пример #1
0
        public static Expression GetInlineMappingBlock(
            IObjectMappingData mappingData,
            MappingValues mappingValues,
            Expression createMappingDataCall)
        {
            var mapper = mappingData.GetOrCreateMapper();

            if (mapper == null)
            {
                return(Constants.EmptyExpression);
            }

            if (mapper.MapperData.Context.UsesMappingDataObject)
            {
                return(UseLocalSourceValueVariable(
                           mapper.MapperData.MappingDataObject,
                           createMappingDataCall,
                           mapper.MappingExpression));
            }

            return(GetDirectAccessMapping(
                       mapper.MappingLambda.Body,
                       mapper.MapperData,
                       mappingValues,
                       createMappingDataCall));
        }
Пример #2
0
        public static Expression GetInlineMappingBlock(
            IObjectMappingData mappingData,
            MappingValues mappingValues,
            Expression createMappingDataCall)
        {
            var mapper = mappingData.GetOrCreateMapper();

            if (mapper == null)
            {
                if (mappingData.HasSameTypedConfiguredDataSource())
                {
                    // Configured data source for an otherwise-unconstructable complex type:
                    return(mappingValues.SourceValue);
                }

                return(Constants.EmptyExpression);
            }

            if (mapper.MapperData.Context.UsesMappingDataObject)
            {
                return(UseLocalValueVariable(
                           mapper.MapperData.MappingDataObject,
                           createMappingDataCall,
                           mapper.MappingExpression));
            }

            return(GetDirectAccessMapping(
                       mapper.MappingLambda.Body,
                       mapper.MapperData,
                       mappingValues,
                       createMappingDataCall));
        }
Пример #3
0
        private void CreateMapperFunc(IObjectMappingData mappingData, bool isLazyLoading = false)
        {
            mappingData.MapperKey.MappingData = mappingData;
            mappingData.MapperKey.MapperData  = mappingData.MapperData;

            MappingLambda = mappingData.GetOrCreateMapper().MappingLambda;

            var typedMappingLambda = (Expression <MapperFunc <TChildSource, TChildTarget> >)MappingLambda;

            _repeatedMappingFunc = typedMappingLambda.Compile();

            if (isLazyLoading)
            {
                _mapperData.GetRootMapperData().Mapper.CacheRepeatedMappingFuncs();
            }

            mappingData.MapperKey.MapperData  = null;
            mappingData.MapperKey.MappingData = null;
        }
Пример #4
0
 internal static MappingPlan For(IObjectMappingData mappingData)
 => new MappingPlan(mappingData.GetOrCreateMapper());