コード例 #1
0
ファイル: StatementBlock.cs プロジェクト: hnjm/trancesql
 void ISqlElement.Render(RenderContext context)
 {
     context.WriteLine("BEGIN");
     context.RenderDelimited(this, context.LineDelimiter);
     context.WriteLine();
     context.Write("END");
 }
コード例 #2
0
 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);
     }
 }
コード例 #3
0
ファイル: Delete.cs プロジェクト: hnjm/trancesql
        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(';');
            }
        }
コード例 #4
0
ファイル: CreateTable.cs プロジェクト: hnjm/trancesql
        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(");");
        }
コード例 #5
0
ファイル: CreateIndex.cs プロジェクト: hnjm/trancesql
        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(");");
        }