迭代SearchResultCollection非常慢 [英] Iterating over SearchResultCollection is Very Slow

查看:64
本文介绍了迭代SearchResultCollection非常慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在运行一个LDAP查询,它返回多个条目并将它们存储在SearchResultCollection中。我正在迭代搜索SearchResultCollection,如下所示:

I'm running an LDAP query that returns multiple entries and stores them inside a SearchResultCollection. I'm iterating over the SearchResultCollection like so:

// results is my SearchResultCollection object
foreach (SearchResult sr in results)  
{
   
... do things to each SearchResult in here ...
}

这似乎是最合理的做法这个,但循环难以置信慢。当我使用调试器逐步完成循环时,我发现这是初始化foreach循环的第一步,花费时间 - 实际迭代是瞬时的。

This seems like the most logical way to do this, but loop is incredibly slow. When I step through the loop with the debugger, I find that it's the very first step of initializing the foreach loop that takes the time - the actual iterations are instantaneous.

此外,当我在调试时查看SearchResultCollection的内容,手表加载变量的内容的时间也一样长。

In addition, when I view the contents of the SearchResultCollection while debugging, the watch takes just as long to load the contents of the variable.

我有一个理论认为SearchResultCollection实际上并不包含完整的SearchResult对象,而是引用Active Directory服务器中的条目,然后在迭代SearchResultCollection对象时单独提取这些条目。
任何人都可以证实这个理论吗?是否有更好(更快)的方法来获取一组LDAP条目?

I have a theory that the SearchResultCollection doesn't actually contain complete SearchResult objects, but rather references to entries in the Active Directory server that are then individually fetched when I iterate over the SearchResultCollection object. Can anyone confirm this theory? And is there a better (faster) way to fetch a set of LDAP entries?

推荐答案


这篇关于迭代SearchResultCollection非常慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆