示例#1
0
        public override void VisitAddExpression(BinaryExpression expr)
        {
            var leftVisitor  = new SelectArgumentsVisitor <TResult>(parent);
            var rightVisitor = new SelectArgumentsVisitor <TResult>(parent);

            leftVisitor.VisitExpression(expr.Left);
            rightVisitor.VisitExpression(expr.Right);

            var joinedProjections = new List <IProjection>();

            joinedProjections.AddRange(leftVisitor.projections);
            joinedProjections.AddRange(rightVisitor.projections);

            IType[] types     = joinedProjections[0].GetTypes(parent.RootCriteria, parent.CriteriaQuery);
            var     useConcat = types[0] is AbstractStringType;
            SqlFunctionProjection projection;

            if (useConcat)
            {
                projection = new SqlFunctionProjection("concat", types[0], joinedProjections.ToArray());
            }
            else
            {
                projection = new SqlFunctionProjection(arithmaticAddition, types[0], joinedProjections.ToArray());
            }
            projections.Add(projection);
        }
示例#2
0
        public override void VisitConditionalExpression(ConditionalExpression expr)
        {
            var visitorTrue = new SelectArgumentsVisitor <TResult>(parent);

            visitorTrue.VisitExpression(expr.IfTrue);

            var visitorFalse = new SelectArgumentsVisitor <TResult>(parent);

            visitorFalse.VisitExpression(expr.IfFalse);

            var visitorCondition = new WhereArgumentsVisitor(parent.RootCriteria);

            visitorCondition.VisitExpression(expr.Test);
            Conjunction conjunction = NHibernate.Expressions.Expression.Conjunction();

            foreach (var criterion in visitorCondition.CurrentCriterions)
            {
                conjunction.Add(criterion);
            }

            projections.Add(
                NHibernate.Expressions.Projections
                .Conditional(conjunction,
                             visitorTrue.ProjectionList,
                             visitorFalse.ProjectionList)
                );
        }
示例#3
0
        public override void VisitConvertExpression(UnaryExpression expr)
        {
            var visitor = new SelectArgumentsVisitor <TResult>(parent);

            visitor.VisitExpression(expr.Operand);
            var list = NHibernate.Expressions.Projections.ProjectionList();

            foreach (var proj in visitor.Projections)
            {
                list.Add(proj);
            }
            var projection = new CastProjection(NHibernateUtil.GuessType(expr.Type), list);

            projections.Add(projection);
        }
示例#4
0
        private void VisitAritmaticOperation(BinaryExpression expr, ISQLFunction arithmaticOperation)
        {
            var leftVisitor  = new SelectArgumentsVisitor <TResult>(parent);
            var rightVisitor = new SelectArgumentsVisitor <TResult>(parent);

            leftVisitor.VisitExpression(expr.Left);
            rightVisitor.VisitExpression(expr.Right);

            var joinedProjections = new List <IProjection>();

            joinedProjections.AddRange(leftVisitor.projections);
            joinedProjections.AddRange(rightVisitor.projections);
            var types      = joinedProjections[0].GetTypes(parent.RootCriteria, parent.CriteriaQuery);
            var projection = new SqlFunctionProjection(arithmaticOperation, types[0], joinedProjections.ToArray());

            projections.Add(projection);
        }