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