2011-05-05 35 views

回答

0

您可以修改NHibernate.Search代碼來處理這個問題,或者使用自定義分頁,IE爲您的搜索獲取點擊數,然後相應地爲頁面指定nhibernate搜索結果。

public IList<TEntity> Search<TEntity>(Query query, bool? active, string orderBy) 
{ 
    var search = NHibernate.Search.Search.CreateFullTextSession(this.session); 

    var total = search.CreateFullTextQuery(query, typeof(TEntity)).ResultSize; 

    var first = 0; 

    var l = new List<TEntity>(); 

    while (total > 0) 
    { 
     l.AddRange(search.CreateFullTextQuery(query, typeof(TEntity)) 
       .SetFirstResult(first) 
       .SetMaxResults(1000) 
       .List<TEntity>()); 

     first += 1000; 
     total -= 1000; 
    } 

    return l; 
} 

參見:IFullTextQuery - exception if there are too may objects