public override void WriteToStream(IndentStream stream) { stream.Write("UPDATE"); if (TopCount != null) { stream.Write(" "); TopCount.WriteToStream(stream); } if (Table != null) { stream.Write(" "); Table.WriteToStream(stream); } if (WithOptions != null && WithOptions.Count > 0) { stream.Write(" WITH("); WithOptions.WriteToStreamWithComma(stream); stream.Write(")"); } stream.Write(" SET "); SetColumnsList.WriteToStreamWithComma(stream); if (OutputList != null && OutputList.Count > 0) { stream.WriteLine(); stream.Write("OUTPUT "); OutputList.WriteToStreamWithComma(stream); } if (IntoExpr != null) { stream.WriteLine(); IntoExpr.WriteToStream(stream); } if (FromTableList != null && FromTableList.Count > 0) { stream.WriteLine(); stream.Write("FROM "); FromTableList.WriteToStreamWithComma(stream); } if (WhereExpr != null) { stream.WriteLine(); stream.Write("WHERE "); WhereExpr.WriteToStream(stream); } }
public override void WriteToStream(IndentStream stream) { stream.Write("INSERT"); if (TopCount != null) { stream.Write(" "); TopCount.WriteToStream(stream); } stream.Write(" "); IntoTable.WriteToStream(stream); if (Columns != null && Columns.Count > 0) { stream.Write(" "); Columns.WriteToStream(stream); } stream.Write(" EXEC "); ExecExpr.WriteToStream(stream); }
public override void WriteToStream(IndentStream stream) { stream.Write("SELECT"); if (TopCount != null) { stream.Write(" "); TopCount.WriteToStream(stream); } stream.Write(" "); foreach (var column in Columns.Select((value, idx) => new { value, idx })) { if (column.idx != 0) { stream.Write(", "); } column.value.WriteToStream(stream); } if (IntoTable != null) { stream.WriteLine(); stream.Write("INTO "); IntoTable.WriteToStream(stream); } if (FromSourceList.Count > 0) { stream.WriteLine(); stream.Write("FROM "); stream.Indent++; for (int i = 0; i < FromSourceList.Count; i++) { if (i != 0) { stream.WriteLine(", "); } var fromSource = FromSourceList[i]; fromSource.WriteToStream(stream); } stream.Indent--; } if (ForXmlExpr != null) { stream.WriteLine(); ForXmlExpr.WriteToStream(stream); } if (PivotExpr != null) { stream.WriteLine(); PivotExpr.WriteToStream(stream); } if (WhereExpr != null) { stream.WriteLine(); stream.Write("WHERE "); WhereExpr.WriteToStream(stream); } if (GroupByList.Count > 0) { stream.WriteLine(); stream.Write("GROUP BY "); GroupByList.WriteToStreamWithComma(stream); } if (Having != null) { stream.WriteLine(); Having.WriteToStream(stream); } if (OrderByList.Count > 0) { stream.WriteLine(); stream.Write("ORDER BY "); OrderByList.WriteToStreamWithComma(stream); } if (OptionExpr != null) { stream.WriteLine(); OptionExpr.WriteToStream(stream); } if (UnionSelectList != null && UnionSelectList.Count > 0) { stream.WriteLine(); UnionSelectList.WriteToStream(stream); } if (IsSemicolon) { stream.Write(" ;"); } }