public IQueryable <TResult> To <TResult>(System.Collections.Generic.IDictionary <string, object> parameters, params string[] membersToExpand)
        {
            var expr = _mappingEngine.CreateMapExpression(_source.ElementType, typeof(TResult), parameters, membersToExpand);

            return(_source.Provider.CreateQuery <TResult>(
                       Expression.Call(
                           null,
                           QueryableSelectMethod.MakeGenericMethod(_source.ElementType, typeof(TResult)),
                           new[] { _source.Expression, Expression.Quote(expr) }
                           )
                       ));
        }
Beispiel #2
0
 /// <summary>
 /// Create an expression tree representing a mapping from the <typeparamref name="TSource"/> type to <typeparamref name="TDestination"/> type
 /// Includes flattening and expressions inside MapFrom member configuration
 /// </summary>
 /// <typeparam name="TSource">Source Type</typeparam>
 /// <typeparam name="TDestination">Destination Type</typeparam>
 /// <param name="mappingEngine">Mapping engine instance</param>
 /// <param name="parameters">Optional parameter object for parameterized mapping expressions</param>
 /// <param name="membersToExpand">Expand members explicitly previously marked as members to explicitly expand</param>
 /// <returns>Expression tree mapping source to destination type</returns>
 public static Expression <Func <TSource, TDestination> > CreateMapExpression <TSource, TDestination>(
     this IMappingEngine mappingEngine, IDictionary <string, object> parameters = null,
     params MemberInfo[] membersToExpand)
 {
     return
         ((Expression <Func <TSource, TDestination> >)
          mappingEngine.CreateMapExpression(typeof(TSource), typeof(TDestination), parameters, membersToExpand));
 }
        private IQueryable <TResult> To <TResult>(IObjectDictionary parameters, MemberInfo[] members)
        {
            var mapExpr = _mappingEngine.CreateMapExpression(_source.ElementType, typeof(TResult), parameters, members);

            return(_source.Provider.CreateQuery <TResult>(
                       Expression.Call(
                           null,
                           QueryableSelectMethod.MakeGenericMethod(_source.ElementType, typeof(TResult)),
                           new[] { _source.Expression, Expression.Quote(mapExpr) }
                           )
                       ));
        }
        public IQueryable <TResult> To <TResult>()
        {
            Expression <Func <TSource, TResult> > expr = _mappingEngine.CreateMapExpression <TSource, TResult>();

            return(_source.Select(expr));
        }
Beispiel #5
0
 /// <summary>
 /// Create an expression tree representing a mapping from the source type to destination type
 /// Includes flattening and expressions inside MapFrom member configuration
 /// </summary>
 /// <param name="mappingEngine">Mapping engine instance</param>
 /// <param name="sourceType">Source Type</param>
 /// <param name="destinationType">Destination Type</param>
 /// <param name="parameters">Optional parameter object for parameterized mapping expressions</param>
 /// <param name="membersToExpand">Expand members explicitly previously marked as members to explicitly expand</param>
 /// <returns>Expression tree mapping source to destination type</returns>
 public static Expression CreateMapExpression(this IMappingEngine mappingEngine,
                                              Type sourceType, Type destinationType,
                                              IDictionary <string, object> parameters = null, params MemberInfo[] membersToExpand)
 {
     return(mappingEngine.CreateMapExpression(sourceType, destinationType, parameters, membersToExpand));
 }