NHibernate.Search - SQL Server 2005 - hitting max parameter limit 2100 !
I am using NHibernate.Search libraries in my project for free text search. Recently when I started getting more than 2100 results, I started getting开发者_高级运维 max parameter length error from SQL Server.
Does NHibernate.Search take care of such situation ? Any workaround anyone ?
You could modify NHibernate.Search code to take care of this, or, use custom paging, IE get number of hits for your search, then page nhibernate search results accordingly.
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;
}
See : IFullTextQuery - exception if there are too may objects
精彩评论