當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。