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); }
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) ); }
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); }
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); }