private static IFutureValue <long> MontarQueryPaginado <T>(IQueryOver <T, T> query, int pagina, int tamanhoPagina) where T : class { IFutureValue <long> count = query.ToRowCountInt64Query().FutureValue <long>(); if (pagina > 0 && tamanhoPagina > 0) { query.Skip((pagina - 1) * tamanhoPagina).Take(tamanhoPagina); } return(count); }
public void TransformQueryOverToRowCount64() { IQueryOver <Person> expected = CreateTestQueryOver <Person>() .Where(p => p.Name == "test") .JoinQueryOver(p => p.Children) .Where((Child c) => c.Age == 5) .Select(Projections.RowCountInt64()); IQueryOver <Person> actual = CreateTestQueryOver <Person>() .Where(p => p.Name == "test") .JoinQueryOver(p => p.Children) .Where((Child c) => c.Age == 5) .OrderBy(c => c.Age).Asc .Skip(20) .Take(10); expected = expected.Clone(); actual = actual.ToRowCountInt64Query(); AssertCriteriaAreEqual(expected.UnderlyingCriteria, actual); }
public IQueryOver <TRoot, TRoot> ToRowCountInt64Query() { return(MainQuery.ToRowCountInt64Query()); }