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


C# SqlQuery.ToString方法代码示例

本文整理汇总了C#中Serenity.Data.SqlQuery.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# SqlQuery.ToString方法的具体用法?C# SqlQuery.ToString怎么用?C# SqlQuery.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Serenity.Data.SqlQuery的用法示例。


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

示例1: DistinctAddsKeyword

        public void DistinctAddsKeyword()
        {
            var query = new SqlQuery()
                .Distinct(true)
                .Select("TestColumn")
                .From("TestTable");

            Assert.Equal(
                TestSqlHelper.Normalize(
                    "SELECT DISTINCT TestColumn FROM TestTable"),
                TestSqlHelper.Normalize(
                    query.ToString()));
        }
开发者ID:nxtayi,项目名称:Serenity,代码行数:13,代码来源:SqlQueryTests.cs

示例2: FromMultipleCallsDoesCrossJoin

        public void FromMultipleCallsDoesCrossJoin()
        {
            var query = new SqlQuery()
                .From("TestTable1")
                .From("TestTable2")
                .Select("TestColumn");

            Assert.Equal(
                TestSqlHelper.Normalize(
                    "SELECT TestColumn FROM TestTable1, TestTable2"),
                TestSqlHelper.Normalize(
                    query.ToString()));
        }
开发者ID:CodeFork,项目名称:Serenity,代码行数:13,代码来源:SqlQueryTests.cs

示例3: DistinctCanBeTurnedOff

        public void DistinctCanBeTurnedOff()
        {
            var query = new SqlQuery()
                .Distinct(true)
                .Select("TestColumn")
                .From("TestTable")
                .Distinct(false);

            Assert.Equal(
                TestSqlHelper.Normalize(
                    "SELECT TestColumn FROM TestTable"),
                TestSqlHelper.Normalize(
                    query.ToString()));
        }
开发者ID:nxtayi,项目名称:Serenity,代码行数:14,代码来源:SqlQueryTests.cs

示例4: FromMixedOverloadsMultipleCallsDoesCrossJoin

        public void FromMixedOverloadsMultipleCallsDoesCrossJoin()
        {
            var query = new SqlQuery()
                .From("TestTable1", new Alias("x1"))
                .From(new Alias("TestTable2", "x2"))
                .From("TestTable3")
                .Select("TestColumn");

            Assert.Equal(
                TestSqlHelper.Normalize(
                    "SELECT TestColumn FROM TestTable1 x1, TestTable2 x2, TestTable3"),
                TestSqlHelper.Normalize(
                    query.ToString()));
        }
开发者ID:nxtayi,项目名称:Serenity,代码行数:14,代码来源:SqlQueryTests.cs

示例5: DoesAutomaticJoinProperlyWithAliasedFields

        public void DoesAutomaticJoinProperlyWithAliasedFields()
        {
            var x = RowMappingTests.ComplexRow.Fields.As("x");

            var query = new SqlQuery()
                    .From(x)
                    .Select(x.CountryName);

            Assert.Equal(
                TestSqlHelper.Normalize(
                    "SELECT x_c.Name AS [CountryName] FROM ComplexTable x " +
                    "LEFT JOIN TheCountryTable x_c ON (x_c.TheCountryID = x.CountryID)"),
                TestSqlHelper.Normalize(
                    query.ToString()));
        }
开发者ID:CodeFork,项目名称:Serenity,代码行数:15,代码来源:SqlQueryAutoJoinTests.cs

示例6: DoesAutomaticJoinProperlyWithAliasedAndJoinedFieldsAndSelect

        public void DoesAutomaticJoinProperlyWithAliasedAndJoinedFieldsAndSelect()
        {
            var x = RowMappingTests.ComplexRow.Fields.As("x");
            var y = RowMappingTests.ComplexRow.Fields.As("y");

            var query = new SqlQuery()
                    .From(x)
                    .LeftJoin(y, y.ID == x.ID)
                    .Select(x.CountryName, "CountryNameX")
                    .Select(y.CountryName, "CountryNameY");

            Assert.Equal(
                TestSqlHelper.Normalize(
                    "SELECT " +
                        "x_c.Name AS [CountryNameX], " +
                        "y_c.Name AS [CountryNameY] " +
                    "FROM ComplexTable x " +
                    "LEFT JOIN ComplexTable y ON (y.ComplexID = x.ComplexID) " +
                    "LEFT JOIN TheCountryTable x_c ON (x_c.TheCountryID = x.CountryID) " +
                    "LEFT JOIN TheCountryTable y_c ON (y_c.TheCountryID = y.CountryID)"),
                TestSqlHelper.Normalize(
                    query.ToString()));
        }
开发者ID:CodeFork,项目名称:Serenity,代码行数:23,代码来源:SqlQueryAutoJoinTests.cs

示例7: DoesAutomaticJoinProperlyWithViewRowIfAllNamesAreSelectedInJoinOrder

        public void DoesAutomaticJoinProperlyWithViewRowIfAllNamesAreSelectedInJoinOrder()
        {
            var fld = ViewRow.Fields;

            var query = new SqlQuery()
                    .From(fld)
                    .Select(fld.District)
                    .Select(fld.City)
                    .Select(fld.Country);

            Assert.Equal(
                TestSqlHelper.Normalize(
                    "SELECT " +
                        "d.Name AS [District], " +
                        "c.Name AS [City], " +
                        "o.Name AS [Country] " +
                    "FROM ViewTable T0 " +
                    "LEFT JOIN Districts d ON (d.DistrictID = T0.DistrictID) " +
                    "LEFT JOIN Cities c ON (c.CityID = d.CityID) " +
                    "LEFT JOIN Countries o ON (o.CountryID = c.CountryID) "),
                TestSqlHelper.Normalize(
                    query.ToString()));
        }
开发者ID:CodeFork,项目名称:Serenity,代码行数:23,代码来源:SqlQueryAutoJoinTests.cs

示例8: OrderByFirstMovesExpressionToStartIfAlreadyInStatement

        public void OrderByFirstMovesExpressionToStartIfAlreadyInStatement()
        {
            var query = new SqlQuery()
                .From("TestTable")
                .Select("a")
                .OrderBy("a")
                .OrderBy("b")
                .OrderBy("c")
                .OrderByFirst("b");

            Assert.Equal(
                TestSqlHelper.Normalize(
                    "SELECT a FROM TestTable ORDER BY b, a, c"),
                TestSqlHelper.Normalize(
                    query.ToString()));
        }
开发者ID:nxtayi,项目名称:Serenity,代码行数:16,代码来源:SqlQueryTests.cs

示例9: OrderByFirstHandlesDescWhileMovingExpressionToFirst

        public void OrderByFirstHandlesDescWhileMovingExpressionToFirst()
        {
            var query1 = new SqlQuery()
                .From("TestTable")
                .Select("a")
                .OrderBy("a")
                .OrderBy("b", desc: true)
                .OrderBy("c")
                .OrderByFirst("b");

            Assert.Equal(
                TestSqlHelper.Normalize(
                    "SELECT a FROM TestTable ORDER BY b, a, c"),
                TestSqlHelper.Normalize(
                    query1.ToString()));

            var query2 = new SqlQuery()
                .From("TestTable")
                .Select("a")
                .OrderBy("a")
                .OrderBy("b")
                .OrderBy("c")
                .OrderByFirst("b", desc: true);

            Assert.Equal(
                TestSqlHelper.Normalize(
                    "SELECT a FROM TestTable ORDER BY b DESC, a, c"),
                TestSqlHelper.Normalize(
                    query2.ToString()));
        }
开发者ID:nxtayi,项目名称:Serenity,代码行数:30,代码来源:SqlQueryTests.cs

示例10: DoesAutomaticJoinProperlyWithViewRowIfAreSelectedInJoinOrderAliased

        public void DoesAutomaticJoinProperlyWithViewRowIfAreSelectedInJoinOrderAliased()
        {
            var vw = ViewRow.Fields.As("vw");

            var query = new SqlQuery()
                    .From(vw)
                    .Select(vw.District)
                    .Select(vw.City)
                    .Select(vw.Country);

            Assert.Equal(
                TestSqlHelper.Normalize(
                    "SELECT " +
                        "vw_d.Name AS [District], " +
                        "vw_c.Name AS [City], " +
                        "vw_o.Name AS [Country] " +
                    "FROM ViewTable vw " +
                    "LEFT JOIN Districts vw_d ON (vw_d.DistrictID = vw.DistrictID) " +
                    "LEFT JOIN Cities vw_c ON (vw_c.CityID = vw_d.CityID) " +
                    "LEFT JOIN Countries vw_o ON (vw_o.CountryID = vw_c.CountryID) "),
                TestSqlHelper.Normalize(
                    query.ToString()));
        }
开发者ID:CodeFork,项目名称:Serenity,代码行数:23,代码来源:SqlQueryAutoJoinTests.cs

示例11: TakeUsesCorrectSyntaxForSqliteDialect

        public void TakeUsesCorrectSyntaxForSqliteDialect()
        {
            var query = new SqlQuery()
                .Dialect(SqliteDialect.Instance)
                .Select("c")
                .From("t")
                .Take(10);

            Assert.Equal(
                TestSqlHelper.Normalize(
                    "SELECT c FROM t LIMIT 10"),
                TestSqlHelper.Normalize(
                    query.ToString()));
        }
开发者ID:nxtayi,项目名称:Serenity,代码行数:14,代码来源:SqlQueryTests.cs

示例12: SubQueryCanBeUsedAsCriteriaUsingWith

        public void SubQueryCanBeUsedAsCriteriaUsingWith()
        {
            var query = new SqlQuery()
                .From("ParentTable")
                .Select("ParentColumn")
                .With(me => me.Where(new Criteria(me.SubQuery()
                    .From("SubTable")
                    .Take(1)
                    .Select("SubColumn")) >= 1));

            Assert.Equal(
                TestSqlHelper.Normalize(
                    "SELECT ParentColumn FROM ParentTable WHERE " +
                        "((SELECT TOP 1 SubColumn FROM SubTable) >= @p1)"),
                TestSqlHelper.Normalize(
                    query.ToString()));
        }
开发者ID:nxtayi,项目名称:Serenity,代码行数:17,代码来源:SqlQueryTests.cs

示例13: DoesAutomaticJoinsIfFromRowUsed

        public void DoesAutomaticJoinsIfFromRowUsed()
        {
            var fld = RowMappingTests.ComplexRow.Fields;

            var query = new SqlQuery()
                    .From(new RowMappingTests.ComplexRow())
                    .Select(fld.CountryName);

            Assert.Equal(
                TestSqlHelper.Normalize(
                    "SELECT c.Name AS [CountryName] FROM ComplexTable T0 " +
                    "LEFT JOIN TheCountryTable c ON (c.TheCountryID = T0.CountryID)"),
                TestSqlHelper.Normalize(
                    query.ToString()));
        }
开发者ID:CodeFork,项目名称:Serenity,代码行数:15,代码来源:SqlQueryAutoJoinTests.cs

示例14: OrderByWithExpressionWorks

        public void OrderByWithExpressionWorks()
        {
            var query = new SqlQuery()
                .Select("TestColumn")
                .From("TestTable")
                .OrderBy("TestColumn")
                .OrderBy("TestColumn2");

            Assert.Equal(
                TestSqlHelper.Normalize(
                    "SELECT TestColumn FROM TestTable ORDER BY TestColumn, TestColumn2"),
                TestSqlHelper.Normalize(
                    query.ToString()));
        }
开发者ID:nxtayi,项目名称:Serenity,代码行数:14,代码来源:SqlQueryTests.cs

示例15: FromWithTableNameAndAliasWorks

        public void FromWithTableNameAndAliasWorks()
        {
            var query = new SqlQuery()
                .From("TestTable", new Alias("TestAlias"))
                .Select("TestColumn");

            Assert.Equal(
                TestSqlHelper.Normalize(
                    "SELECT TestColumn FROM TestTable TestAlias"),
                TestSqlHelper.Normalize(
                    query.ToString()));
        }
开发者ID:nxtayi,项目名称:Serenity,代码行数:12,代码来源:SqlQueryTests.cs


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