Ejemplo n.º 1
0
        public async Task ExecuteAsync <TData>(IDbConnection connection, IDataDescriptor descriptor,
                                               DocumentDbBatchOptions options,
                                               object userState, BatchSaveStrategy saveStrategy, IEnumerable <TData> objects, long startingAt = 0,
                                               int?count          = null, IDbTransaction transaction = null,
                                               int?commandTimeout = null, CancellationToken cancellationToken = default)
        {
            var client     = DocumentDbBulkExecutor.RequisitionBulkCopyClient(connection.GetClient());
            var collection = (DocumentCollection)userState;
            var databaseId = connection.GetDatabaseId();

            await DocumentDbBulkExecutor.ExecuteAsync(descriptor, _timestamps, saveStrategy, objects, startingAt, count,
                                                      client, databaseId, collection);
        }
Ejemplo n.º 2
0
        public Task <(DocumentDbBatchOptions, object)> BeforeAsync(IDbConnection connection,
                                                                   IDataDescriptor descriptor, IDbTransaction transaction = null, int?commandTimeout = null)
        {
            var client     = DocumentDbBulkExecutor.RequisitionBulkCopyClient(connection.GetClient());
            var databaseId = connection.GetDatabaseId();

            var documentCollection = client.CreateDocumentCollectionQuery(UriFactory.CreateDatabaseUri(databaseId))
                                     .Where(c => c.Id == _options.Value.CollectionId)
                                     .AsEnumerable().FirstOrDefault();

            (DocumentDbBatchOptions, object)result = (_batchOptions.Value, documentCollection);
            return(Task.FromResult(result));
        }