NHibernate:如何选择已排序的父/子项并仅检索特定的行号

NHibernate:如何选择已排序的父/子项并仅检索特定的行号,nhibernate,queryover,row-number,Nhibernate,Queryover,Row Number,我有两个表:Parent和Child,它们具有以下关系:Parent有许多Child public class Parent { public DateTime Timestamp; public IList<Child> Child; } public Child { public string Name; } 公共类父类 { 公共日期时间戳; 公共教育和儿童教育; } 公共儿童 { 公共字符串名称; } 我想选择父级和子级,按时间戳排序,只获取索引

我有两个表:Parent和Child,它们具有以下关系:Parent有许多Child

public class Parent
{
    public  DateTime Timestamp;
    public  IList<Child> Child;
}
public Child
{
    public string Name;
}
公共类父类
{
公共日期时间戳;
公共教育和儿童教育;
}
公共儿童
{
公共字符串名称;
}
我想选择父级和子级,按时间戳排序,只获取索引x到y之间的行

public IList<Parent> Get(DateTime from, DateTime to, int startRow, int count)
{
    QueryOver<Parent>().Where(row => row.Timestamp >= from)
    .And(row => row.Timestamp <= to).OrderBy(row => row.Timestamp).Asc.List();
}
public IList Get(DateTime from、DateTime to、int startRow、int count)
{
QueryOver().Where(行=>row.Timestamp>=from)
.And(row=>row.Timestamp row.Timestamp).Asc.List();
}
我不知道如何只获取所需的行

我应该和QueryOver一起做吗?还是在HQL中执行更好


谢谢

我更改了关系,不再使用父表和子表,我只使用一个表:

public class Info
{
    public  DateTime Timestamp;
    public string Name;
}
为了获取日期之间的所有记录,我使用以下方法对它们进行排序并从索引startRow到startRow+count进行获取:

public IList<Info> GetInfo (DateTime fromDate, DateTime toDate, int startRow, int count)
{
    IList<Info> result = 
    QueryOver<Info>()
    .Where(row => row.Timestamp >= fromDate)
    .And(row => row.Timestamp <= toDate)
    .OrderBy(row => row.Timestamp).Asc
    .Skip(startRow).Take(count).List();
    return result;
}
public IList GetInfo(DateTime fromDate、DateTime toDate、int startRow、int count)
{
IList结果=
QueryOver()
.Where(row=>row.Timestamp>=fromDate)
.And(row=>row.Timestamp row.Timestamp).Asc
.Skip(startRow).Take(count).List();
返回结果;
}
结果SQL为:

SELECT * FROM Info WHERE timestamp >= :fromDate AND timestamp <= :toDate 
ORDER BY timestamp ASC OFFSET :startRow ROWS FETCH NEXT :count ROWS ONLY

SELECT*FROM Info WHERE timestamp>=:fromDate和timestamp您是说您想急切地加载孩子及其家长吗?是的,我还想过滤结果以仅检索行的范围当您说“行的范围”时,您是指行x和y之间的所有家长,例如,类似于
从父级选择*,其中RowNum介于:x和:y之间