Esempio n. 1
0
        public override void VisitJoinClause(JoinClause joinClause, QueryModel queryModel, int index)
        {
            _queryParts.AddInnerJoinPart(
                GetPsqlExpression(joinClause.OuterKeySelector),
                GetPsqlExpression(joinClause.InnerKeySelector));

            base.VisitJoinClause(joinClause, queryModel, index);
        }
Esempio n. 2
0
        /// Adds an INNER JOIN part of the SQL query as FROM parts, while replacing corresponding FROM parts.
        ///
        /// If a subquery parts aggregator is open, redirects the call to it instead.
        public void AddInnerJoinPart(string leftMember, string rightMember)
        {
            if (_visitingSubQueryExpression)
            {
                _subQueryExpressionPartsAggregator.AddInnerJoinPart(leftMember, rightMember);
            }
            else
            {
                var leftSource  = leftMember.Split('.')[0];
                var rightSource = rightMember.Split('.')[0];
                var joinPart    =
                    $"{leftSource} INNER JOIN {rightSource} ON ({leftMember} = {rightMember})";

                // We're using the fact that the left source table was already added in AddFromPart
                var index = FromParts.IndexOf(leftSource);
                FromParts[index] = joinPart;
            }
        }