本文整理汇总了Java中com.activeandroid.query.From.count方法的典型用法代码示例。如果您正苦于以下问题:Java From.count方法的具体用法?Java From.count怎么用?Java From.count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.activeandroid.query.From
的用法示例。
在下文中一共展示了From.count方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCountOrderBy
import com.activeandroid.query.From; //导入方法依赖的package包/类
/**
* Should not change the result if order by is used.
*/
public void testCountOrderBy() {
cleanTable();
populateTable();
From from = new Select()
.from(MockModel.class)
.where("intField = ?", 1)
.orderBy("intField ASC");
final List<MockModel> list = from.execute();
final int count = from.count();
assertEquals(2, count);
assertEquals(list.size(), count);
}
示例2: testCountGroupBy
import com.activeandroid.query.From; //导入方法依赖的package包/类
/**
* Should return the total number of rows, even if the rows are grouped. May seem weird, just
* test it in an SQL explorer.
*/
public void testCountGroupBy() {
cleanTable();
populateTable();
From from = new Select()
.from(MockModel.class)
.groupBy("intField")
.having("intField = 1");
final List<MockModel> list = from.execute();
final int count = from.count();
assertEquals(2, count);
assertEquals(1, list.size());
}
示例3: testCountTable
import com.activeandroid.query.From; //导入方法依赖的package包/类
/**
* Should return the same count as there are entries in the result set/table.
*/
public void testCountTable() {
cleanTable();
populateTable();
From from = new Select()
.from(MockModel.class);
final List<MockModel> list = from.execute();
final int count = from.count();
assertEquals(3, count);
assertEquals(list.size(), count);
}
示例4: testCountWhereClause
import com.activeandroid.query.From; //导入方法依赖的package包/类
/**
* Should return the same count as there are entries in the result set if the where-clause
* matches several entries.
*/
public void testCountWhereClause() {
cleanTable();
populateTable();
From from = new Select()
.from(MockModel.class)
.where("intField = ?", 1);
final List<MockModel> list = from.execute();
final int count = from.count();
assertEquals(2, count);
assertEquals(list.size(), count);
}
示例5: testCountEmptyResult
import com.activeandroid.query.From; //导入方法依赖的package包/类
/**
* Should return the same count as there are entries in the result set if the where-clause
* matches zero entries.
*/
public void testCountEmptyResult() {
cleanTable();
populateTable();
From from = new Select()
.from(MockModel.class)
.where("intField = ?", 3);
final List<MockModel> list = from.execute();
final int count = from.count();
assertEquals(0, count);
assertEquals(list.size(), count);
}