コード例 #1
0
        /// <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);
        }
コード例 #2
0
        /// <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);
        }
コード例 #3
0
        /// <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));
        }
コード例 #4
0
        /// <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));
            }
        }