Exemplo n.º 1
0
            /// <summary>
            /// Finds the all documents in the collection up to <paramref name="limit"/>.
            /// </summary>
            /// <param name="filter">
            /// A document describing the find criteria using <see href="https://docs.mongodb.com/manual/reference/operator/query/">query operators</see>.
            /// If not specified, all documents in the collection will be returned.
            /// </param>
            /// <param name="sort">A document describing the sort criteria. If not specified, the order of the returned documents is not guaranteed.</param>
            /// <param name="projection">
            /// A document describing the fields to return for all matching documents. If not specified, all fields are returned.
            /// </param>
            /// <param name="limit">The maximum number of documents to return. If not specified, all documents in the collection are returned.</param>
            /// <returns>
            /// An awaitable <see cref="Task"/> representing the remote find operation. The result of the task is an array containing the documents that match the find criteria.
            /// </returns>
            /// <seealso href="https://docs.mongodb.com/manual/reference/method/db.collection.find/"/>
            public async Task <TDocument[]> FindAsync(object filter = null, object sort = null, object projection = null, long?limit = null)
            {
                var result = await _handle.Find(filter?.ToNativeJson(), FindAndModifyOptions.Find(projection, sort, limit));

                return(result.GetValue <TDocument[]>());
            }