Example #1
0
        /// <inheritdoc/>
        protected override ISqlNode OnChildNode(ISqlNode node)
        {
            if (node.NodeName == "from_source") {
                Source = (IFromSourceNode) node.ChildNodes.FirstOrDefault();
            } else if (node.NodeName == "join_opt") {
                Join = (JoinNode) node.ChildNodes.FirstOrDefault();
            }

            return base.OnChildNode(node);
        }
Example #2
0
        private static void AddSourceToClause(FromClause clause, IFromSourceNode source)
        {
            string alias = null;
            if (source.Alias != null)
                alias = source.Alias.Text;

            if (source is FromTableSourceNode) {
                var tableSource = (FromTableSourceNode)source;
                clause.AddTable(alias, tableSource.TableName.Name);
            } else if (source is FromQuerySourceNode) {
                var querySource = (FromQuerySourceNode)source;
                var queryExpression = (SqlQueryExpression) Build(querySource.Query);
                clause.AddSubQuery(alias, queryExpression);
            }
        }
Example #3
0
        private static void AddSourceToClause(FromClause clause, IFromSourceNode source)
        {
            string alias = null;

            if (source.Alias != null)
            {
                alias = source.Alias.Text;
            }

            if (source is FromTableSourceNode)
            {
                var tableSource = (FromTableSourceNode)source;
                clause.AddTable(alias, tableSource.TableName.Name);
            }
            else if (source is FromQuerySourceNode)
            {
                var querySource     = (FromQuerySourceNode)source;
                var queryExpression = (SqlQueryExpression)Build(querySource.Query);
                clause.AddSubQuery(alias, queryExpression);
            }
        }
Example #4
0
        private static void SetFromTableInClause(FromClause clause, IFromSourceNode source, JoinNode join)
        {
            AddSourceToClause(clause, source);

            if (join != null)
            {
                var joinType = JoinType.Inner;
                if (!String.IsNullOrEmpty(join.JoinType))
                {
                    joinType = GetJoinType(join.JoinType);
                }

                SqlExpression onExpression = null;
                if (join.OnExpression != null)
                {
                    onExpression = Build(join.OnExpression);
                }

                clause.Join(joinType, onExpression);

                SetFromTableInClause(clause, join.Source, join.NextJoin);
            }
        }
Example #5
0
        /// <inheritdoc/>
        protected override ISqlNode OnChildNode(ISqlNode node)
        {
            if (node.NodeName == "join_type") {
                GetJoinType(node);
            } else if (node is IFromSourceNode) {
                Source = (IFromSourceNode) node;
            } else if (node.NodeName == "from_source") {
                Source = (IFromSourceNode) node.ChildNodes.FirstOrDefault();
            } else if (node.NodeName == "on_opt") {
                OnExpression = node.FindNode<IExpressionNode>();
            } else if (node.NodeName == "join_opt") {
                var join = node.ChildNodes.FirstOrDefault();
                if (join != null)
                    NextJoin = (JoinNode) join;
            }

            return base.OnChildNode(node);
        }
Example #6
0
        private void SetFromTableInClause(FromClause clause, IFromSourceNode source, JoinNode join)
        {
            AddSourceToClause(clause, source);

            if (join != null) {
                var joinType = JoinType.Inner;
                if (!String.IsNullOrEmpty(join.JoinType))
                    joinType = GetJoinType(join.JoinType);

                SqlExpression onExpression = null;
                if (join.OnExpression != null)
                    onExpression = Build(join.OnExpression);

                clause.Join(joinType, onExpression);

                SetFromTableInClause(clause, join.Source, join.NextJoin);
            }
        }