Beispiel #1
0
        public NhLinqExpression(Expression expression)
        {
            _expression = PartialEvaluatingExpressionTreeVisitor.EvaluateIndependentSubtrees(expression);

            _expression = NameUnNamedParameters.Visit(_expression);

            _constantToParameterMap = ExpressionParameterVisitor.Visit(_expression);

            ParameterValuesByName = _constantToParameterMap.Values.ToDictionary(p => p.Name,
                                                                                p =>
                                                                                new Tuple <object, IType>
            {
                First = p.Value, Second = p.Type
            });

            Key = ExpressionKeyVisitor.Visit(_expression, _constantToParameterMap);

            Type = _expression.Type;

            // Note - re-linq handles return types via the GetOutputDataInfo method, and allows for SingleOrDefault here for the ChoiceResultOperator...
            ReturnType = NhLinqExpressionReturnType.Scalar;

            if (typeof(IQueryable).IsAssignableFrom(Type))
            {
                Type       = Type.GetGenericArguments()[0];
                ReturnType = NhLinqExpressionReturnType.Sequence;
            }
        }
        public static Expression Visit(Expression expression)
        {
            var visitor = new NameUnNamedParameters();

            return visitor.VisitExpression(expression);
        }