Exemplo n.º 1
0
        private Expression CreateItemMappingExpression(ParameterExpression from)
        {
            if (this.aItemMapping.ResolvedMapping is IDirectMapping)
            {
                return(from);
            }

            var mapMethod = Delegate.CreateDelegate(
                typeof(Func <,>).MakeGenericType(EnumerableReflection <TFrom> .ItemType, EnumerableReflection <TTo> .ItemType),
                this.aItemMapping.ResolvedMapping,
                MappingMethods.Map(EnumerableReflection <TFrom> .ItemType, EnumerableReflection <TTo> .ItemType)
                );

            return(Expression.Call(null, LinqMethods.Select(EnumerableReflection <TFrom> .ItemType, EnumerableReflection <TTo> .ItemType),
                                   from,
                                   Expression.Constant(mapMethod)
                                   ));
        }