Exemplo n.º 1
0
            /// <summary>
            /// Inserts the provided document in the collection.
            /// </summary>
            /// <param name="doc">The document to insert.</param>
            /// <returns>
            /// An awaitable <see cref="Task{T}"/> representing the remote insert operation. The result of the task
            /// contains the <c>_id</c> of the inserted document.
            /// </returns>
            /// <seealso href="https://docs.mongodb.com/manual/reference/method/db.collection.insertOne/"/>
            public async Task <InsertResult> InsertOneAsync(TDocument doc)
            {
                Argument.NotNull(doc, nameof(doc));

                var result = await _handle.InsertOne(doc.ToNativeJson());

                return(result.GetValue <InsertResult>());
            }