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


C# Builder.SelectSqlBuilder类代码示例

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


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


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