为DirectorySearcher.SizeLimit = 1的FindAll()等于FindOne()的DirectoryServices / .NET]FindAll、SizeLimit、Dir

由网友(牵佑手╮卟弃)分享简介:在使用.NET的DirectorySearcher从,是这两个语句平等吗?When using the DirectorySearcher in .net, are these two statements equal?同时适用于:Dim ds As New DirectorySearcher' code to...

在使用.NET的DirectorySearcher从,是这两个语句平等吗?

When using the DirectorySearcher in .net, are these two statements equal?

同时适用于:

Dim ds As New DirectorySearcher
' code to setup the searcher

首先声明

ds.FindOne()

第二条语句

ds.SizeLimit = 1
ds.FindAll()

...但显然这FindOne()返回一个信息搜索结果对象的FindAll()返回一个SearchResultCollection对象

...except obviously that FindOne() returns a SearchResult object and FindAll() returns a SearchResultCollection object

推荐答案

是的,这将是差不多了。

Yes, that would be almost the same.

差不多,因为在.NET 2.0(不知道,如果它被固定在新的版本),该.FindOne()调用曾与内存泄露的一些问题,所以最好的做法是(或曾经)总是使用.FindAll( ),并遍历结果。

Almost, because in .NET 2.0 (not sure if it's been fixed in more recent versions), the .FindOne() call had some issues with leaking memory, so best practice is (or was) to always use .FindAll() and iterate over your results.

马克·

阅读全文

相关推荐

最新文章