• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Builder.SelectSqlBuilder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: AndWhereThrowsArgumentExceptionForNullPredicate

        public void AndWhereThrowsArgumentExceptionForNullPredicate()
        {
            var sqlBuilder = new SelectSqlBuilder(SqlCharacters.Empty);

            var exception = Assert.Throws<ArgumentException>(
                () => sqlBuilder.AndWhere(null, new object()));

            Assert.Equal(ExceptionMessages.ArgumentNullOrEmpty.FormatWith("predicate"), exception.Message);
        }
开发者ID:natarajanmca11,项目名称:MicroLite,代码行数:9,代码来源:SelectSqlBuilderTests.cs


示例2: AverageThrowsArgumentExceptionForNullColumnAlias

        public void AverageThrowsArgumentExceptionForNullColumnAlias()
        {
            var sqlBuilder = new SelectSqlBuilder(SqlCharacters.Empty);

            var exception = Assert.Throws<ArgumentException>(
                () => sqlBuilder.Average("Column", null));

            Assert.Equal(ExceptionMessages.ArgumentNullOrEmpty.FormatWith("columnAlias"), exception.Message);
        }
开发者ID:rubenalves,项目名称:MicroLite,代码行数:9,代码来源:SelectSqlBuilderTests.cs


示例3: AndWhereThrowsArgumentExceptionForEmptyColumn

        public void AndWhereThrowsArgumentExceptionForEmptyColumn()
        {
            var sqlBuilder = new SelectSqlBuilder(SqlCharacters.Empty);

            var exception = Assert.Throws<ArgumentException>(
                () => sqlBuilder.AndWhere(""));

            Assert.Equal(ExceptionMessages.ArgumentNullOrEmpty.FormatWith("column"), exception.Message);
        }
开发者ID:natarajanmca11,项目名称:MicroLite,代码行数:9,代码来源:SelectSqlBuilderTests.cs


示例4: AndWhereThrowsArgumentNullExceptionForEmptyArgs

        public void AndWhereThrowsArgumentNullExceptionForEmptyArgs()
        {
            var sqlBuilder = new SelectSqlBuilder(SqlCharacters.Empty);

            var exception = Assert.Throws<ArgumentNullException>(
                () => sqlBuilder.AndWhere("x = ?", null));

            Assert.Equal("args", exception.ParamName);
        }
开发者ID:natarajanmca11,项目名称:MicroLite,代码行数:9,代码来源:SelectSqlBuilderTests.cs


示例5: SelectDistinctColumnWithSqlCharacters

        public void SelectDistinctColumnWithSqlCharacters()
        {
            var sqlBuilder = new SelectSqlBuilder(MsSqlCharacters.Instance, (string)null);

            var sqlQuery = sqlBuilder
                .Distinct("CreditLimit")
                .From(typeof(Customer))
                .ToSqlQuery();

            Assert.Equal("SELECT DISTINCT [CreditLimit] FROM [Sales].[Customers]", sqlQuery.CommandText);
            Assert.Equal(0, sqlQuery.Arguments.Count);
        }
开发者ID:natarajanmca11,项目名称:MicroLite,代码行数:12,代码来源:SelectSqlBuilderTests.cs


示例6: SelectDistinctColumn

        public void SelectDistinctColumn()
        {
            var sqlBuilder = new SelectSqlBuilder(SqlCharacters.Empty, (string)null);

            var sqlQuery = sqlBuilder
                .Distinct("CreditLimit")
                .From(typeof(Customer))
                .ToSqlQuery();

            Assert.Equal("SELECT DISTINCT CreditLimit FROM Sales.Customers", sqlQuery.CommandText);
            Assert.Equal(0, sqlQuery.Arguments.Count);
        }
开发者ID:natarajanmca11,项目名称:MicroLite,代码行数:12,代码来源:SelectSqlBuilderTests.cs


示例7: SelectFromWhereOr

        public void SelectFromWhereOr()
        {
            var sqlBuilder = new SelectSqlBuilder(SqlCharacters.Empty, "Column1", "Column2");

            var sqlQuery = sqlBuilder
                .From("Table")
                .Where("Column1").IsEqualTo("Foo")
                .OrWhere("Column2").IsEqualTo("Bar")
                .ToSqlQuery();

            Assert.Equal("SELECT Column1,Column2 FROM Table WHERE (Column1 = ?) OR (Column2 = ?)", sqlQuery.CommandText);

            Assert.Equal(2, sqlQuery.Arguments.Count);

            Assert.Equal(DbType.String, sqlQuery.Arguments[0].DbType);
            Assert.Equal("Foo", sqlQuery.Arguments[0].Value);

            Assert.Equal(DbType.String, sqlQuery.Arguments[1].DbType);
            Assert.Equal("Bar", sqlQuery.Arguments[1].Value);
        }
开发者ID:natarajanmca11,项目名称:MicroLite,代码行数:20,代码来源:SelectSqlBuilderTests.cs


示例8: NotBetweenThrowsArgumentExceptionForNullUpper

        public void NotBetweenThrowsArgumentExceptionForNullUpper()
        {
            var sqlBuilder = new SelectSqlBuilder(SqlCharacters.Empty);

            var exception = Assert.Throws<ArgumentNullException>(
                () => sqlBuilder.NotBetween(1, null));

            Assert.Equal("upper", exception.ParamName);
        }
开发者ID:natarajanmca11,项目名称:MicroLite,代码行数:9,代码来源:SelectSqlBuilderTests.cs


示例9: SelectFromSpecifyingColumnsAndTableNameWithSqlCharacters

        public void SelectFromSpecifyingColumnsAndTableNameWithSqlCharacters()
        {
            var sqlBuilder = new SelectSqlBuilder(MsSqlCharacters.Instance, "Column1", "Column2");

            var sqlQuery = sqlBuilder
                .From("Table")
                .ToSqlQuery();

            Assert.Equal("SELECT [Column1],[Column2] FROM [Table]", sqlQuery.CommandText);
            Assert.Empty(sqlQuery.Arguments);
        }
开发者ID:natarajanmca11,项目名称:MicroLite,代码行数:11,代码来源:SelectSqlBuilderTests.cs


示例10: SelectFromOrderByDescendingWithSqlCharacters

        public void SelectFromOrderByDescendingWithSqlCharacters()
        {
            var sqlBuilder = new SelectSqlBuilder(MsSqlCharacters.Instance, "Column1", "Column2");

            var sqlQuery = sqlBuilder
                .From("Table")
                .OrderByDescending("Column1", "Column2")
                .ToSqlQuery();

            Assert.Equal("SELECT [Column1],[Column2] FROM [Table] ORDER BY [Column1] DESC,[Column2] DESC", sqlQuery.CommandText);
            Assert.Empty(sqlQuery.Arguments);
        }
开发者ID:natarajanmca11,项目名称:MicroLite,代码行数:12,代码来源:SelectSqlBuilderTests.cs


示例11: SelectAverageWithOtherColumn

        public void SelectAverageWithOtherColumn()
        {
            var sqlBuilder = new SelectSqlBuilder(SqlCharacters.Empty, "Id");

            var sqlQuery = sqlBuilder
                .Average("CreditLimit")
                .From(typeof(Customer))
                .Where("CustomerStatusId").IsEqualTo(CustomerStatus.Active)
                .GroupBy("CustomerStatusId")
                .ToSqlQuery();

            Assert.Equal("SELECT Id,AVG(CreditLimit) AS CreditLimit FROM Sales.Customers WHERE (CustomerStatusId = ?) GROUP BY CustomerStatusId", sqlQuery.CommandText);

            Assert.Equal(1, sqlQuery.Arguments.Count);

            Assert.Equal(DbType.Int32, sqlQuery.Arguments[0].DbType);
            Assert.Equal(CustomerStatus.Active, sqlQuery.Arguments[0].Value);
        }
开发者ID:natarajanmca11,项目名称:MicroLite,代码行数:18,代码来源:SelectSqlBuilderTests.cs


示例12: SelectAverageWithAlias

        public void SelectAverageWithAlias()
        {
            var sqlBuilder = new SelectSqlBuilder(SqlCharacters.Empty, (string)null);

            var sqlQuery = sqlBuilder
                .Average("CreditLimit", columnAlias: "AverageCreditLimit")
                .From(typeof(Customer))
                .Where("CustomerStatusId").IsEqualTo(CustomerStatus.Active)
                .ToSqlQuery();

            Assert.Equal("SELECT AVG(CreditLimit) AS AverageCreditLimit FROM Sales.Customers WHERE (CustomerStatusId = ?)", sqlQuery.CommandText);

            Assert.Equal(1, sqlQuery.Arguments.Count);

            Assert.Equal(DbType.Int32, sqlQuery.Arguments[0].DbType);
            Assert.Equal(CustomerStatus.Active, sqlQuery.Arguments[0].Value);
        }
开发者ID:natarajanmca11,项目名称:MicroLite,代码行数:17,代码来源:SelectSqlBuilderTests.cs


示例13: OrderByDescendingThrowsArgumentNullException

        public void OrderByDescendingThrowsArgumentNullException()
        {
            var sqlBuilder = new SelectSqlBuilder(SqlCharacters.Empty, "CustomerId");

            Assert.Throws<ArgumentException>(
                () => sqlBuilder.From("Customer").OrderByDescending((string)null));

            Assert.Throws<ArgumentException>(
                () => sqlBuilder.From("Customer").OrderByDescending(string.Empty));

            Assert.Throws<ArgumentNullException>(
                () => sqlBuilder.From("Customer").OrderByDescending((string[])null));
        }
开发者ID:natarajanmca11,项目名称:MicroLite,代码行数:13,代码来源:SelectSqlBuilderTests.cs


示例14: OrderByDescendingAppendsColumnsCorrectlyForSingleColumn

        public void OrderByDescendingAppendsColumnsCorrectlyForSingleColumn()
        {
            var sqlBuilder = new SelectSqlBuilder(SqlCharacters.Empty, "CustomerId");

            var sqlQuery = sqlBuilder.From("Customer")
                .OrderByDescending("CustomerId")
                .ToSqlQuery();

            Assert.Equal("SELECT CustomerId FROM Customer ORDER BY CustomerId DESC", sqlQuery.CommandText);
        }
开发者ID:natarajanmca11,项目名称:MicroLite,代码行数:10,代码来源:SelectSqlBuilderTests.cs


示例15: OrderByAscendingAppendsColumnsCorrectlyForMultipleColumns

        public void OrderByAscendingAppendsColumnsCorrectlyForMultipleColumns()
        {
            var sqlBuilder = new SelectSqlBuilder(SqlCharacters.Empty, "CustomerId");

            var sqlQuery = sqlBuilder.From("Customer")
                .OrderByAscending("FirstName", "LastName")
                .ToSqlQuery();

            Assert.Equal("SELECT CustomerId FROM Customer ORDER BY FirstName ASC,LastName ASC", sqlQuery.CommandText);
        }
开发者ID:natarajanmca11,项目名称:MicroLite,代码行数:10,代码来源:SelectSqlBuilderTests.cs


示例16: NotInThrowsArgumentNullExceptionForNullSqlQuery

        public void NotInThrowsArgumentNullExceptionForNullSqlQuery()
        {
            var sqlBuilder = new SelectSqlBuilder(SqlCharacters.Empty, "CustomerId");

            Assert.Throws<ArgumentNullException>(
                () => sqlBuilder.From("Customer").Where("Column").NotIn((SqlQuery)null));
        }
开发者ID:natarajanmca11,项目名称:MicroLite,代码行数:7,代码来源:SelectSqlBuilderTests.cs


示例17: NotExistsThrowArgumentNullExceptionForNullSqlQuery

        public void NotExistsThrowArgumentNullExceptionForNullSqlQuery()
        {
            var sqlBuilder = new SelectSqlBuilder(SqlCharacters.Empty);

            var exception = Assert.Throws<ArgumentNullException>(
                () => sqlBuilder.From("Customer").Where().NotExists(null));

            Assert.Equal("subQuery", exception.ParamName);
        }
开发者ID:natarajanmca11,项目名称:MicroLite,代码行数:9,代码来源:SelectSqlBuilderTests.cs


示例18: SelectChainingMultipleFunctions

        public void SelectChainingMultipleFunctions()
        {
            var sqlBuilder = new SelectSqlBuilder(SqlCharacters.Empty, "Column1");

            var sqlQuery = sqlBuilder
                .Count("Column2", "Col2")
                .Max("Column3", "Col3")
                .From("Table")
                .ToSqlQuery();

            Assert.Equal("SELECT Column1,COUNT(Column2) AS Col2,MAX(Column3) AS Col3 FROM Table", sqlQuery.CommandText);
            Assert.Empty(sqlQuery.Arguments);
        }
开发者ID:natarajanmca11,项目名称:MicroLite,代码行数:13,代码来源:SelectSqlBuilderTests.cs


示例19: SelectFromOrderByDescendingThenAscending

        public void SelectFromOrderByDescendingThenAscending()
        {
            var sqlBuilder = new SelectSqlBuilder(SqlCharacters.Empty, "Column1", "Column2");

            var sqlQuery = sqlBuilder
                .From("Table")
                .OrderByDescending("Column1")
                .OrderByAscending("Column2")
                .ToSqlQuery();

            Assert.Equal("SELECT Column1,Column2 FROM Table ORDER BY Column1 DESC,Column2 ASC", sqlQuery.CommandText);
            Assert.Empty(sqlQuery.Arguments);
        }
开发者ID:natarajanmca11,项目名称:MicroLite,代码行数:13,代码来源:SelectSqlBuilderTests.cs


示例20: SelectFromSpecifyingColumnsAndTypeWithSqlCharacters

        public void SelectFromSpecifyingColumnsAndTypeWithSqlCharacters()
        {
            var sqlBuilder = new SelectSqlBuilder(MsSqlCharacters.Instance, "Name", "DateOfBirth");

            var sqlQuery = sqlBuilder
                .From(typeof(Customer))
                .ToSqlQuery();

            Assert.Equal("SELECT [Name],[DateOfBirth] FROM [Sales].[Customers]", sqlQuery.CommandText);
            Assert.Empty(sqlQuery.Arguments);
        }
开发者ID:natarajanmca11,项目名称:MicroLite,代码行数:11,代码来源:SelectSqlBuilderTests.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# TestEntities.Customer类代码示例发布时间:2022-05-26
下一篇:
C# Models.WMContext类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap