private Expression Prepare(Expression cachedExpression, ParameterBag parameters) { Expression result; if (parameters.Any()) { var visitor = new ConstantExpressionReplacementVisitor(parameters); result = visitor.Visit(cachedExpression); } else { result = cachedExpression; } // perform null-propagation if this feature is enabled. if (_configurationProvider.EnableNullPropagationForQueryMapping) { var nullVisitor = new NullsafeQueryRewriter(); return(nullVisitor.Visit(result)); } return(result); }
private Expression Prepare(Expression cachedExpression, object parameters) { Expression result; if (parameters != null) { var visitor = ParameterExpressionVisitor.Create(parameters); result = visitor.Visit(cachedExpression); } else { result = cachedExpression; } // perform null-propagation if this feature is enabled. if (_configurationProvider.EnableNullPropagationForQueryMapping) { var nullVisitor = new NullsafeQueryRewriter(); return(nullVisitor.Visit(result)); } return(result); }
public Expression CreateMapExpression(Type sourceType, Type destinationType, IDictionary <string, object> parameters = null, params MemberInfo[] membersToExpand) { parameters = parameters ?? new Dictionary <string, object>(); var cachedExpression = _expressionCache.GetOrAdd(new ExpressionRequest(sourceType, destinationType, membersToExpand, null)); Expression x = cachedExpression; if (parameters.Any()) { var visitor = new ConstantExpressionReplacementVisitor(parameters); x = visitor.Visit(cachedExpression); } // perform null-propagation if this feature is enabled. if (_configurationProvider.EnableNullPropagationForQueryMapping) { var nullVisitor = new NullsafeQueryRewriter(); return(nullVisitor.Visit(x)); } return(x); }