public Max ( string columnName ) : IFunctionOrFrom | ||
columnName | string | |
Résultat | IFunctionOrFrom |
public void MaxThrowsArgumentExceptionForNullColumnAlias() { var sqlBuilder = new SelectSqlBuilder(SqlCharacters.Empty); var exception = Assert.Throws<ArgumentException>( () => sqlBuilder.Max("Column", null)); Assert.Equal(ExceptionMessages.ArgumentNullOrEmpty.FormatWith("columnAlias"), exception.Message); }
public void SelectMaxWithOtherColumn() { var sqlBuilder = new SelectSqlBuilder(SqlCharacters.Empty, "Id"); var sqlQuery = sqlBuilder .Max("CreditLimit") .From(typeof(Customer)) .Where("CustomerStatusId").IsEqualTo(CustomerStatus.Active) .ToSqlQuery(); Assert.Equal("SELECT Id,MAX(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 SelectMaxWithSqlCharacters() { var sqlBuilder = new SelectSqlBuilder(MsSqlCharacters.Instance, (string)null); var sqlQuery = sqlBuilder .Max("CreditLimit") .From(typeof(Customer)) .Where("CustomerStatusId").IsEqualTo(CustomerStatus.Active) .ToSqlQuery(); Assert.Equal("SELECT MAX([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 SelectMaxWithAlias() { var sqlBuilder = new SelectSqlBuilder(SqlCharacters.Empty, (string)null); var sqlQuery = sqlBuilder .Max("CreditLimit", columnAlias: "MaxCreditLimit") .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 MAX(CreditLimit) AS MaxCreditLimit FROM Sales.Customers WHERE (CustomerStatusId = ?)", sqlQuery.CommandText); }