Min() public method

public Min ( string columnName ) : IFunctionOrFrom
columnName string
return IFunctionOrFrom
        public void MinThrowsArgumentExceptionForNullColumnAlias()
        {
            var sqlBuilder = new SelectSqlBuilder(SqlCharacters.Empty);

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

            Assert.Equal(ExceptionMessages.ArgumentNullOrEmpty.FormatWith("columnAlias"), exception.Message);
        }
        public void SelectMinWithOtherColumn()
        {
            var sqlBuilder = new SelectSqlBuilder(SqlCharacters.Empty, "Id");

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

            Assert.Equal("SELECT Id,MIN(CreditLimit) AS CreditLimit 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);
        }
        public void SelectMinWithSqlCharacters()
        {
            var sqlBuilder = new SelectSqlBuilder(MsSqlCharacters.Instance, (string)null);

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

            Assert.Equal("SELECT MIN([CreditLimit]) AS CreditLimit FROM [Sales].[Customers] WHERE ([CustomerStatusId] = @p0)", sqlQuery.CommandText);

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

            Assert.Equal(DbType.Int32, sqlQuery.Arguments[0].DbType);
            Assert.Equal(CustomerStatus.Active, sqlQuery.Arguments[0].Value);
        }
        public void SelectMin()
        {
            var sqlBuilder = new SelectSqlBuilder(SqlCharacters.Empty, (string)null);

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

            Assert.Equal(1, sqlQuery.Arguments.Count);
            Assert.Equal(CustomerStatus.Active, sqlQuery.Arguments[0]);

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