/// <summary>
        /// Returns the only document of the aggregate result, or the default value if the result set is empty. Throws an exception if the result set contains more than one document.
        /// </summary>
        /// <typeparam name="TResult">The type of the result.</typeparam>
        /// <param name="aggregate">The aggregate.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>
        /// The fluent aggregate interface.
        /// </returns>
        public static Task <TResult> SingleOrDefaultAsync <TResult>(this IAggregateFluent <TResult> aggregate, CancellationToken cancellationToken = default(CancellationToken))
        {
            Ensure.IsNotNull(aggregate, nameof(aggregate));

            return(IAsyncCursorSourceExtensions.SingleOrDefaultAsync(aggregate.Limit(2), cancellationToken));
        }
        /// <summary>
        /// Returns the first document of the aggregate result, or the default value if the result set is empty.
        /// </summary>
        /// <typeparam name="TResult">The type of the result.</typeparam>
        /// <param name="aggregate">The aggregate.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>
        /// The fluent aggregate interface.
        /// </returns>
        public static TResult FirstOrDefault <TResult>(this IAggregateFluent <TResult> aggregate, CancellationToken cancellationToken = default(CancellationToken))
        {
            Ensure.IsNotNull(aggregate, nameof(aggregate));

            return(IAsyncCursorSourceExtensions.FirstOrDefault(aggregate.Limit(1), cancellationToken));
        }
        /// <summary>
        /// Get the first result or null.
        /// </summary>
        /// <typeparam name="TDocument">The type of the document.</typeparam>
        /// <typeparam name="TProjection">The type of the projection (same as TDocument if there is no projection).</typeparam>
        /// <param name="find">The fluent find.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>A Task whose result is the first result or null.</returns>
        public static Task <TProjection> FirstOrDefaultAsync <TDocument, TProjection>(this IFindFluent <TDocument, TProjection> find, CancellationToken cancellationToken = default(CancellationToken))
        {
            Ensure.IsNotNull(find, nameof(find));

            return(IAsyncCursorSourceExtensions.FirstOrDefaultAsync(find.Limit(1), cancellationToken));
        }