IFullTextQuery-如果对象也太多,则为异常
此代码可以正常工作:
Query query = parser.Parse(expression);
IFullTextSession session = Search.CreateFullTextSession(this.Session);
IFullTextQuery fullTextQuery = session.CreateFullTextQuery(query, new[] { typeof(MappedSequence) });
var l1 = fullTextQuery.List();
,只要查询不返回太多对象即可.如果查询包含太多对象,则生成的sql代码太长,并且sql server引发异常.一种可行的解决方案是使用相当慢的分页来获取所有对象.有更好的解决方案吗?
as long as the query does not return too many objects. If the query contains too many objects the generated sql code is too long and sql server throws an exception. One working solution is to obtain all objects using paging which is fairly slow. Is there a better solution?
谢谢.
C
如果我没记错的话,fullTextQuery.List()做得很大
If I remember correctly, fullTextQuery.List() does a big
select ... where ID_COL IN ( id1, id2, id3, id4 ... )
其中id1,id2 ...是参数,该数字在SQL Server中受到限制.这样,您就可以从Lucene文档中获得NHibernate实体.长话短说,除了分页之外,没有其他解决方法.
where id1, id2 ... are parameters, which number is limited in SQL Server. This way, you get NHibernate entities from lucene documents. Long story short, there is no workaround, except paging.
如果您确实需要获取大量数据,则可以使用1000个元素的页面大小.
You can use page size of 1000 elements, if you REALLY need to get this much of data.
在某处获取1000个实体会很慢:例如,当您在屏幕上显示它们时.
Getting 1000's of entities would be slow somewhere : when you display them on screen, for exemple.