public void GroupByWithHaving() { GroupedEmployeeResults r = new GroupedEmployeeResults(); q = Select.Results(r.DepartmentID). From(e). Columns(e.DepartmentID.As(r.DepartmentID)). GroupBy(e.DepartmentID). Having(Count.All() > 1); AssertSql("SELECT DepartmentID FROM Employee GROUP BY DepartmentID HAVING COUNT(*) > 1"); AssertRowCount(1); AssertRow(1); }
public void GroupByWithCountAll() { GroupedEmployeeResults r = new GroupedEmployeeResults(); q = Select.Results(r.DepartmentID, r.Count). From(e). Columns(e.DepartmentID.As(r.DepartmentID), Count.All().As(r.Count)). GroupBy(e.DepartmentID); AssertSql("SELECT DepartmentID, COUNT(*) Count FROM Employee GROUP BY DepartmentID"); AssertRowCount(4); AssertRow(1, 3); AssertRow(2, 1); AssertRow(3, 1); AssertRow(DBNull.Value, 1); }