/// <inheritdoc/>
        public async Task InsertAsync <TItem>(IEnumerable <TItem> items, Action <JsonInsert <TEntity> > insertAction, CancellationToken cancellationToken)
        {
            if (items == null)
            {
                throw new ArgumentNullException(nameof(items));
            }

            var jsonInsert = new JsonInsert <TEntity>(this.RepositoryProvider.DatabaseContext);

            insertAction?.Invoke(jsonInsert);
            await jsonInsert.ExecuteAsync(items, cancellationToken).ConfigureAwait(false);
        }
        /// <summary>
        /// Inserts a list of items into the repository.
        /// </summary>
        /// <param name="items">
        /// The items to insert.
        /// </param>
        /// <param name="insertAction">
        /// The insert action to take, or null to take the default insert action.
        /// </param>
        /// <typeparam name="TItem">
        /// The type of item to insert..
        /// </typeparam>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="items"/> is null.
        /// </exception>
        public void Insert <TItem>(IEnumerable <TItem> items, Action <JsonInsert <TEntity> > insertAction)
        {
            if (items == null)
            {
                throw new ArgumentNullException(nameof(items));
            }

            var jsonInsert = new JsonInsert <TEntity>(this.RepositoryProvider.DatabaseContext);

            insertAction?.Invoke(jsonInsert);
            jsonInsert.Execute(items);
        }
        /// <summary>
        /// Inserts a list of items into the repository.
        /// </summary>
        /// <param name="items">
        /// The items to insert.
        /// </param>
        /// <param name="insertAction">
        /// The insert action to take, or null to take the default insert action.
        /// </param>
        /// <typeparam name="TItem">
        /// The type of item to insert..
        /// </typeparam>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="items"/> is null.
        /// </exception>
        /// <returns>
        /// An <see cref="IEnumerable{T}"/> of <typeparamref name="TItem"/> items.
        /// </returns>
        public IEnumerable <TItem> InsertForResults <TItem>(
            IEnumerable <TItem> items,
            Action <JsonInsert <TEntity> > insertAction)
        {
            if (items == null)
            {
                throw new ArgumentNullException(nameof(items));
            }

            var jsonInsert = new JsonInsert <TEntity>(this.RepositoryProvider.DatabaseContext);

            insertAction?.Invoke(jsonInsert);
            var insertedEntities = jsonInsert.ExecuteForResults(items);

            return(this.EntityMapper.Map <List <TItem> >(insertedEntities));
        }
        /// <inheritdoc/>
        public async IAsyncEnumerable <TItem> InsertForResultsAsync <TItem>(
            IEnumerable <TItem> items,
            Action <JsonInsert <TEntity> > insertAction,
            [EnumeratorCancellation] CancellationToken cancellationToken)
        {
            if (items == null)
            {
                throw new ArgumentNullException(nameof(items));
            }

            var jsonInsert = new JsonInsert <TEntity>(this.RepositoryProvider.DatabaseContext);

            insertAction?.Invoke(jsonInsert);

            await foreach (var item in jsonInsert.ExecuteForResultsAsync(items, cancellationToken).ConfigureAwait(false))
            {
                yield return(this.EntityMapper.Map <TItem>(item));
            }
        }