当前位置: 首页>>代码示例>>C#>>正文


C# FormattingEngine类代码示例

本文整理汇总了C#中FormattingEngine的典型用法代码示例。如果您正苦于以下问题:C# FormattingEngine类的具体用法?C# FormattingEngine怎么用?C# FormattingEngine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FormattingEngine类属于命名空间,在下文中一共展示了FormattingEngine类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Can_Format_Begin_End_Block_With_If_Statement

        public void Can_Format_Begin_End_Block_With_If_Statement()
        {
            // Setup
            var sut = new FormattingEngine();

            // Exercise
            var actual = sut.Execute( "IF @A > 1 BEGIN SELECT TOP 20 Field1, Field2 FROM dbo.Table T END" );

            // Verify outcome
            var expected = new[]
            {
               @"IF @A > 1",
               @"BEGIN",
                "",
                "    SELECT TOP 20",
                "        Field1,",
                "        Field2",
                "",
                "    FROM dbo.Table T",
                "",
                "END"
            };

            Compare( actual, expected );
        }
开发者ID:Bigjono,项目名称:sqlformat,代码行数:25,代码来源:TestBlockStatementFormatting.cs

示例2: Can_Format_Select_Statement_With_Group_By_Multiple_Columns_With_Having_Clause

        public void Can_Format_Select_Statement_With_Group_By_Multiple_Columns_With_Having_Clause()
        {
            // Setup
            var sut = new FormattingEngine();

            // Exercise
            var actual = sut.Execute( "SELECT COUNT(*) FROM dbo.Table T GROUP BY A.FieldID, B.FieldID, C.FieldID HAVING COUNT(*) > 1" );

            // Verify outcome
            var expected = new[]
            {
               @"SELECT COUNT(*)",
                "",
                "FROM dbo.Table T",
                "",
                "GROUP BY",
                "    A.FieldID,",
                "    B.FieldID,",
                "    C.FieldID",
                "",
                "HAVING COUNT(*) > 1"
            };

            Compare( actual, expected );
        }
开发者ID:jtmueller,项目名称:sqlformat,代码行数:25,代码来源:TestSelectStatementFormatting.cs

示例3: btnConvert_Click

        protected void btnConvert_Click( object sender, EventArgs e )
        {
            string output = "";

            var engine = new FormattingEngine();
            try
            {
                var timer = new System.Diagnostics.Stopwatch();
                timer.Start();
                try
                {
                    output = engine.Execute( sqlInput.Text );
                }
                finally
                {
                    timer.Stop();
                }
                timeTaken.Text = timer.ElapsedMilliseconds.ToString( "0:00:0000" );
            }
            catch ( Exception ex )
            {
                output = "ERROR" + Environment.NewLine + ex.ToString();
            }
            sqlOutput.DataSource = output.Split( new[] { "\r\n" }, StringSplitOptions.None );
            sqlOutput.DataBind();
        }
开发者ID:Bigjono,项目名称:sqlformat,代码行数:26,代码来源:Default.aspx.cs

示例4: Can_Format_Simple_Create_Statement

        public void Can_Format_Simple_Create_Statement()
        {
            // Setup
            var sut = new FormattingEngine();

            // Exercise
            var actual = sut.Execute( @"

                create table Test
                (
                    id1 [int] NOT NULL IDENTITY(100, 1),
                    id2 varchar(10)
                )" );

            // Verify outcome
            var expected = new[]
            {
                "CREATE TABLE [dbo].[Clients]",
                "(",
                "    [ClientID] [int] IDENTITY(1,1) NOT NULL,",
                "    [Name] [nvarchar](255) NOT NULL",
                ")"
            };

            Compare( actual, expected );
        }
开发者ID:Bigjono,项目名称:sqlformat,代码行数:26,代码来源:TestCreateStatementFormatting.cs

示例5: Can_Format_Update_Statement_With_Joins

        public void Can_Format_Update_Statement_With_Joins()
        {
            // Setup
            var sut = new FormattingEngine();

            // Exercise
            var actual = sut.Execute(
                @"UPDATE T SET Name = O.Name FROM dbo.Table T JOIN dbo.OtherJoin AS O ON O.ID = T.ID
                  AND O.Num = T.Num AND O.Field = 0 LEFT JOIN dbo.Joined J ON T.ID = J.ID AND J.Field = 1"
            );

            // Verify outcome
            var expected = new[]
            {
                "UPDATE T",
                "   SET Name = O.Name",
                "",
                "FROM dbo.Table T",
                "",
                "JOIN dbo.OtherJoin AS O",
                "  ON O.ID = T.ID",
                " AND O.Num = T.Num",
                " AND O.Field = 0",
                "",
                "LEFT JOIN dbo.Joined J",
                "       ON T.ID = J.ID",
                "      AND J.Field = 1"
            };

            Compare( actual, expected );
        }
开发者ID:Bigjono,项目名称:sqlformat,代码行数:31,代码来源:TestUpdateStatementFormatting.cs

示例6: Can_Format_Insert_Statement_With_Column_Listing_And_Select_Values

        public void Can_Format_Insert_Statement_With_Column_Listing_And_Select_Values()
        {
            // Setup
            var sut = new FormattingEngine();

            // Exercise
            var actual = sut.Execute( @"
                Insert into dbo.Table ( ID, Greeting, MaxiumumDaysBetweenEvents, Description, EffectiveFromDate,
                EffectiveToDate ) SELECT ID, Greeting, MaxiumumDaysBetweenEvents * 2, Description, EffectiveFromDate,
                EffectiveToDate FROM dbo.Events WHERE IsCancelled = 1 "
            );

            // Verify outcome
            var expected = new[]
            {
               "INSERT INTO dbo.Table (",
               "    ID, Greeting, MaxiumumDaysBetweenEvents, Description, EffectiveFromDate, EffectiveToDate",
               "    )",
               "    SELECT",
               "        ID,",
               "        Greeting,",
               "        MaxiumumDaysBetweenEvents * 2,",
               "        Description,",
               "        EffectiveFromDate,",
               "        EffectiveToDate",
               "",
               "    FROM dbo.Events",
               "",
               "    WHERE IsCancelled = 1",

            };

            Compare( actual, expected );
        }
开发者ID:Bigjono,项目名称:sqlformat,代码行数:34,代码来源:TestInsertStatementFormatting.cs

示例7: Can_Create_Formatting_Engine

        public void Can_Create_Formatting_Engine()
        {
            // Setup
            var sut = new FormattingEngine();

            // Exercise

            // Verify outcome
            Assert.IsNotNull( sut );
        }
开发者ID:jtmueller,项目名称:sqlformat,代码行数:10,代码来源:TestSelectStatementFormatting.cs

示例8: Can_Format_Simple_Create_Index_Statement

        public void Can_Format_Simple_Create_Index_Statement()
        {
            // Setup
            var sut = new FormattingEngine();

            // Exercise
            var actual = sut.Execute( @"CREATE UNIQUE NONCLUSTERED INDEX [IX_Sites_Code] ON dbo.Sites (Code) WITH (IGNORE_DUP_KEY = ON )" );

            // Verify outcome
            var expected = new[]
            {
                "CREATE UNIQUE NONCLUSTERED INDEX [IX_Sites_Code] ON dbo.Sites ( Code ) WITH ( IGNORE_DUP_KEY = ON )"
            };

            Compare( actual, expected );
        }
开发者ID:Bigjono,项目名称:sqlformat,代码行数:16,代码来源:TestCreateStatementFormatting.cs

示例9: Can_Format_Delete_Statement_With_Top_N

        public void Can_Format_Delete_Statement_With_Top_N()
        {
            // Setup
            var sut = new FormattingEngine();

            // Exercise
            var actual = sut.Execute( "DELETE TOP (10) FROM dbo.Table" );

            // Verify outcome
            var expected = new[]
            {
               @"DELETE TOP (10)",
                "FROM dbo.Table"
            };

            Compare( actual, expected );
        }
开发者ID:Bigjono,项目名称:sqlformat,代码行数:17,代码来源:TestDeleteStatementFormatting.cs

示例10: Can_Format_Simple_Update_Statement

        public void Can_Format_Simple_Update_Statement()
        {
            // Setup
            var sut = new FormattingEngine();

            // Exercise
            var actual = sut.Execute( "UPDATE dbo.Table SET Field1 = 'Value'" );

            // Verify outcome
            var expected = new[]
            {
               @"UPDATE dbo.Table",
                "   SET Field1 = 'Value'"
            };

            Compare( actual, expected );
        }
开发者ID:Bigjono,项目名称:sqlformat,代码行数:17,代码来源:TestUpdateStatementFormatting.cs

示例11: Can_Format_Few_Column_Insert_Statement_With_Column_Listing

        public void Can_Format_Few_Column_Insert_Statement_With_Column_Listing()
        {
            // Setup
            var sut = new FormattingEngine();

            // Exercise
            var actual = sut.Execute( "Insert into dbo.Table (ID, Greeting) VALUES (1, 'Hello World')" );

            // Verify outcome
            var expected = new[]
            {
               "INSERT INTO dbo.Table (ID, Greeting)",
               "     VALUES (1, 'Hello World')"
            };

            Compare( actual, expected );
        }
开发者ID:Bigjono,项目名称:sqlformat,代码行数:17,代码来源:TestInsertStatementFormatting.cs

示例12: Can_Format_Select_With_Multiple_Froms_With_Joins

        public void Can_Format_Select_With_Multiple_Froms_With_Joins()
        {
            // Setup
            var sut = new FormattingEngine();

            // Exercise
            var sql = @"exec sp_executesql
                  N'select TOP (@p0) T.Id, T.Name from [Transaction] T
                    where T.Type in (''Process'', ''TransferFrom'')
                      and T.Code in (@p1) and T.Name <> @p2',
                  N'@p0 int,@p1 int,@p2 nvarchar(4000)',
                  @p0=100,@p1=44,@p2=N'WOO'
            ";

            var actual = sut.Execute(sql);

            // Verify outcome
            var expected = new[]
            {
               @"DECLARE",
                "    @p0 int,",
                "    @p1 int,",
                "    @p2 nvarchar(4000)",
                "",
                "SELECT",
                "    @p0 = 100,",
                "    @p1 = 44,",
                "    @p2 = N'WOO'",
                "",
                "SELECT TOP (@p0)",
                "    T.Id,",
                "    T.Name",
                "",
                "FROM [Transaction] T",
                "",
                "WHERE T.Type IN ('Process', 'TransferFrom')",
                "  AND T.Code IN (@p1)",
                "  AND T.Name <> @p2"
            };

            Compare(actual, expected);
        }
开发者ID:jtmueller,项目名称:sqlformat,代码行数:42,代码来源:TestExecuteSqlStatementFormatting.cs

示例13: Can_Format_Simple_Select_Statement

        public void Can_Format_Simple_Select_Statement()
        {
            // Setup
            var sut = new FormattingEngine();

            // Exercise
            var actual = sut.Execute( "SELECT TOP 20 Field1, Field2 FROM dbo.Table T" );

            // Verify outcome
            var expected = new[]
            {
               @"SELECT TOP 20",
                "    Field1,",
                "    Field2",
                "",
                "FROM dbo.Table T",
            };

            Compare( actual, expected );
        }
开发者ID:Bigjono,项目名称:sqlformat,代码行数:20,代码来源:TestGoTerminatorStatementFormatting.cs

示例14: Can_Format_Select_With_Between_Expression

        public void Can_Format_Select_With_Between_Expression()
        {
            // Setup
            var sut = new FormattingEngine();

            // Exercise
            var actual = sut.Execute(
                @"SELECT * FROM dbo.Table A WHERE A.Field BETWEEN 10 AND (SELECT TOP 1 ID FROM Keys )"
            );

            // Verify outcome
            var expected = new[]
            {
                "SELECT *",
                "FROM dbo.Table A",
                "WHERE A.Field BETWEEN 10 AND (SELECT TOP 1 ID FROM Keys)",
            };

            Compare( actual, expected );
        }
开发者ID:Bigjono,项目名称:sqlformat,代码行数:20,代码来源:TestExpressionFormatting.cs

示例15: Can_Format_Delete_Statement_With_Multiple_Condition_Where_Clause

        public void Can_Format_Delete_Statement_With_Multiple_Condition_Where_Clause()
        {
            // Setup
            var sut = new FormattingEngine();

            // Exercise
            var actual = sut.Execute( "Delete T FROM dbo.Table T WHERE T.TableID = 10 AND T.Data IS NULL" );

            // Verify outcome
            var expected = new[]
            {
               @"DELETE T",
                "",
                "FROM dbo.Table T",
                "",
                "WHERE T.TableID = 10",
                "  AND T.Data IS NULL"
            };

            Compare( actual, expected );
        }
开发者ID:Bigjono,项目名称:sqlformat,代码行数:21,代码来源:TestDeleteStatementFormatting.cs


注:本文中的FormattingEngine类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。