void ISqlElement.Render(RenderContext context) { context.WriteLine("BEGIN"); context.RenderDelimited(this, context.LineDelimiter); context.WriteLine(); context.Write("END"); }
void ISqlElement.Render(RenderContext context) { context.Write("IF ("); context.Render(Condition?.Value ?? throw new InvalidCommandException("IF condition must not be null.")); context.WriteLine(")"); context.Render(Then ?? throw new InvalidCommandException("Then statement of IF condition must not be null.")); if (Else != null) { context.WriteLine(); context.WriteLine("ELSE"); context.Render(Else); } }
void ISqlElement.Render(RenderContext context) { var output = OutputType.None; if (_returning?.Any() == true) { output = context.Dialect.OutputType; if (output == OutputType.None) { throw new InvalidCommandException("This dialect does not support return clauses in delete statements."); } } using (context.EnterChildMode(RenderMode.Nested)) { context.Write("DELETE FROM "); context.Render(_from.Value); // OUTPUT statements are rendered before where clauses if (output == OutputType.Output) { context.WriteLine(); context.Write("OUTPUT "); context.RenderDelimited(_returning); } if (Where != null) { context.WriteLine(); context.Write("WHERE "); context.Render(Where.Value); } // RETURNING statements are rendered after where clauses if (output == OutputType.Returning) { context.WriteLine(); context.Write("RETURNING "); context.RenderDelimited(_returning); } context.Write(';'); } }
void ISqlElement.Render(RenderContext context) { if (Name == null) { throw new InvalidCommandException("Create table statement must specify a name."); } context.Write("CREATE TABLE "); context.Render(Name); context.WriteLine(); context.WriteLine("("); context.RenderDelimited(Columns, "," + context.LineDelimiter); foreach (var constraint in Constraints) { context.WriteLine(","); context.Render(constraint); } context.WriteLine(); context.Write(");"); }
void ISqlElement.Render(RenderContext context) { if (Unique) { context.Write("CREATE UNIQUE INDEX "); } else { context.Write("CREATE INDEX "); } context.WriteIdentifier(Name); context.WriteLine(); context.Write("ON "); context.Render(On); context.Write('('); context.RenderDelimited(Columns); context.Write(");"); }