Esempio n. 1
0
        private void AddJoin(JoinClause joinClause, QueryModel queryModel, bool innerJoin)
        {
            var         equalityVisitor = new EqualityHqlGenerator(VisitorParameters);
            var         withClause      = equalityVisitor.Visit(joinClause.InnerKeySelector, joinClause.OuterKeySelector);
            var         alias           = _hqlTree.TreeBuilder.Alias(VisitorParameters.QuerySourceNamer.GetName(joinClause));
            var         joinExpression  = HqlGeneratorExpressionVisitor.Visit(joinClause.InnerSequence, VisitorParameters);
            HqlTreeNode join;

            // When associations are located inside the inner key selector we have to use a cross join instead of an inner
            // join and add the condition in the where statement.
            if (queryModel.BodyClauses.OfType <NhJoinClause>().Any(o => o.ParentJoinClause == joinClause))
            {
                if (!innerJoin)
                {
                    throw new NotSupportedException("Left joins that have association properties in the inner key selector are not supported.");
                }

                _hqlTree.AddWhereClause(withClause);
                join = CreateCrossJoin(joinExpression, alias);
            }
            else
            {
                join = innerJoin
                                        ? _hqlTree.TreeBuilder.InnerJoin(joinExpression.AsExpression(), alias)
                                        : (HqlTreeNode)_hqlTree.TreeBuilder.LeftJoin(joinExpression.AsExpression(), alias);
                join.AddChild(_hqlTree.TreeBuilder.With(withClause));
            }

            _hqlTree.AddFromClause(join);
        }
Esempio n. 2
0
        public override void VisitJoinClause(JoinClause joinClause, QueryModel queryModel, int index)
        {
            var equalityVisitor = new EqualityHqlGenerator(VisitorParameters);
            var whereClause     = equalityVisitor.Visit(joinClause.InnerKeySelector, joinClause.OuterKeySelector);

            _hqlTree.AddWhereClause(whereClause);

            _hqlTree.AddFromClause(_hqlTree.TreeBuilder.Range(HqlGeneratorExpressionTreeVisitor.Visit(joinClause.InnerSequence, VisitorParameters),
                                                              _hqlTree.TreeBuilder.Alias(joinClause.ItemName)));
        }
Esempio n. 3
0
        private void AddJoin(JoinClause joinClause, QueryModel queryModel, bool innerJoin)
        {
            var equalityVisitor = new EqualityHqlGenerator(VisitorParameters);
            var withClause      = equalityVisitor.Visit(joinClause.InnerKeySelector, joinClause.OuterKeySelector);
            var alias           = _hqlTree.TreeBuilder.Alias(VisitorParameters.QuerySourceNamer.GetName(joinClause));
            var joinExpression  = HqlGeneratorExpressionVisitor.Visit(joinClause.InnerSequence, VisitorParameters);
            var join            = innerJoin
                                ? _hqlTree.TreeBuilder.InnerJoin(joinExpression.AsExpression(), alias)
                                : (HqlTreeNode)_hqlTree.TreeBuilder.LeftJoin(joinExpression.AsExpression(), alias);

            join.AddChild(_hqlTree.TreeBuilder.With(withClause));
            _hqlTree.AddFromClause(join);
        }
Esempio n. 4
0
        public override void VisitJoinClause(JoinClause joinClause, QueryModel queryModel, int index)
        {
            var         equalityVisitor = new EqualityHqlGenerator(VisitorParameters);
            var         withClause      = equalityVisitor.Visit(joinClause.InnerKeySelector, joinClause.OuterKeySelector);
            var         alias           = _hqlTree.TreeBuilder.Alias(VisitorParameters.QuerySourceNamer.GetName(joinClause));
            var         joinExpression  = HqlGeneratorExpressionVisitor.Visit(joinClause.InnerSequence, VisitorParameters);
            HqlTreeNode join;

            // When associations are located inside the inner key selector we have to use a cross join instead of an inner
            // join and add the condition in the where statement.
            if (queryModel.BodyClauses.OfType <NhJoinClause>().Any(o => o.ParentJoinClause == joinClause))
            {
                _hqlTree.AddWhereClause(withClause);
                join = CreateCrossJoin(joinExpression, alias);
            }
            else
            {
                join = _hqlTree.TreeBuilder.InnerJoin(joinExpression.AsExpression(), alias);
                join.AddChild(_hqlTree.TreeBuilder.With(withClause));
            }

            _hqlTree.AddFromClause(join);
        }
		public override void VisitJoinClause(JoinClause joinClause, QueryModel queryModel, int index)
		{
			var equalityVisitor = new EqualityHqlGenerator(VisitorParameters);
			var whereClause = equalityVisitor.Visit(joinClause.InnerKeySelector, joinClause.OuterKeySelector);

			_hqlTree.AddWhereClause(whereClause);

			_hqlTree.AddFromClause(
				_hqlTree.TreeBuilder.Range(
					HqlGeneratorExpressionTreeVisitor.Visit(joinClause.InnerSequence, VisitorParameters),
					_hqlTree.TreeBuilder.Alias(joinClause.ItemName)));
		}