MarkLogic XCC/.Net Library |

# ResultSequence Methods

The methods of the ResultSequence interface are listed below. For a complete list of ResultSequence interface members, see the ResultSequence Members topic.

#### Public Instance Methods

Close | Release any resources being held by this ResultSequence. If cached, this is a no-op an the cached ResultItems are retained (let the ResultSequence go out of scope to cause the cached data to be reclaimed). If not cached, this ResultSequence will be invalidated and its ResultItem members will no longer be accessible.
GetChannel | Return the ResultSequence for an alternate ResultChannelName. The ResultSequence returned by Session.submitRequest(Request) is the sequence of XdmItems representing the XQuery result. But there may be alternate channels (each comprising a ResultSequence instance) associated with the result. This method returns the sequence for the given channel. The ResultSequence returned by Session.submitRequest(Request) is always ResultChannelName.PRIMARY. A ResultSequence instance is always returned by this method, though it may be empty.
GetEnumerator | Returns a java.util.Iterator instance that may be used to iterate over this result sequence. Each object returned by the Iterator is an instance of ResultItem.
HasNext | Returns true if this sequence contains another item beyond the currently active one. Initially, the result sequence is positioned before the first item, if any, and this method will return false if the sequence is empty. Note that if the current item is large (node, binary, text) and has not yet been fully consumed by the client, it's value may be flushed and lost as the result stream is positioned to the next item.
ItemAt | Returns the XdmItem wrapped by the ResultItem at the given index.
Next | Advance the logical cursor to the next ResultItem in this ResultSequence and return that item. The logical cursor is initially positioned before the first item in the sequence. Unlike Iterator.next(), this method returns null when there is no next item.
Reset | Reset the internal positional index (cursor) of this ResultSequence to before the first ResultItem in the sequence. This operation is only supported if Cached is true.
ResultItemAt | Returns the ResultItem from this ResultSequence, if possible, at the given positional index. Accessing ResultItems randomly has restrictions if Cached is true. For streaming ResultSequences, if index is equal to the current position, then the current ResultItem is returned. If index is less than the current position, then an exception is thrown. If index is greater than the current position, then items in the sequence are read and discarded until the requested position is achieved. If the requested item is found, it is returned. If the end of the sequence is encountered while trying to seek to the requested position, an exception is thrown.
Size | Returns the number of ResultItems, if known, in this ResultSequence. For streaming (non-cached) ResultSequences, ResultItems are processed sequentially from the communication channel and so the size of the full sequence is not known during iteration.
ToCached | Produce a cached version of this ResultSequence. If the provided ResultSequence is already cached (Cached is true), then nothing is done and this instance returns itself. Otherwise, a new, cached ResultSequence instance is created and populated with the XdmItems in the sequence. If the non-cached input ResultSequence has been partially iterated, only the remaining XdmItems will be cached. If the current item is not fetchable (ResultItem.Fetchable is false), it will be ignored.
ToResultItemArray | This method is identical to the superclass method ToArray(), but returns an array typed as ResultItem. If the ResultSequence is streaming (Cached is false), then it is consumed and closed after building the returned array. Note also that AsStrings() when called on a ResultSequence will call this method internally, which will also result in the object being closed automatically. Note that for a streaming ResultSequence, all items will be loaded into memory to build the array. If very large items (node(), text(), etc) are in the stream, it's possible that there may not be enough memory to buffer everything. If the sequence contains too much data to buffer, iterate over each item and use ResultItem.AsStream() to read each item in turn as a Stream.
ToString | Return a textual description of this ResultSequence object, NOT the value of the items in the sequence. Use the AsString() or AsStrings() methods to obtain String representations of the item values.

#### See Also

ResultSequence Interface | Marklogic.Xcc Namespace