当前位置: 首页>>代码示例>>C#>>正文


C# BulkMixedWriteOperation类代码示例

本文整理汇总了C#中BulkMixedWriteOperation的典型用法代码示例。如果您正苦于以下问题:C# BulkMixedWriteOperation类的具体用法?C# BulkMixedWriteOperation怎么用?C# BulkMixedWriteOperation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BulkMixedWriteOperation类属于命名空间,在下文中一共展示了BulkMixedWriteOperation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: When

 protected override void When()
 {
     var subject = new BulkMixedWriteOperation(CollectionNamespace, _requests, MessageEncoderSettings)
     {
         MaxBatchCount = _maxBatchCount,
     };
     _result = ExecuteOperationAsync(subject).GetAwaiter().GetResult();
 }
开发者ID:bollinim,项目名称:mongo-csharp-driver,代码行数:8,代码来源:When_there_are_fewer_updates_than_maxBatchCount.cs

示例2: When

 protected override void When()
 {
     var subject = new BulkMixedWriteOperation(DatabaseName, CollectionName, _requests)
     {
         IsOrdered = true
     };
     _exception = Catch<BulkWriteException>(() => ExecuteOperationAsync(subject).GetAwaiter().GetResult());
 }
开发者ID:Nakro,项目名称:mongo-csharp-driver,代码行数:8,代码来源:When_first_batch_has_an_error_and_is_ordered_is_true.cs

示例3: When

 protected override void When()
 {
     var subject = new BulkMixedWriteOperation(DatabaseName, CollectionName, _requests)
     {
         MaxBatchCount = _maxBatchCount,
     };
     _result = ExecuteOperationAsync(subject).GetAwaiter().GetResult();
 }
开发者ID:Nakro,项目名称:mongo-csharp-driver,代码行数:8,代码来源:When_there_are_fewer_inserts_than_maxBatchCount.cs

示例4: When

 protected override void When()
 {
     var subject = new BulkMixedWriteOperation(CollectionNamespace, _requests, MessageEncoderSettings)
     {
         IsOrdered = false
     };
     _exception = Catch<BulkWriteOperationException>(() => ExecuteOperationAsync(subject).GetAwaiter().GetResult());
 }
开发者ID:bollinim,项目名称:mongo-csharp-driver,代码行数:8,代码来源:When_first_batch_has_an_error_and_is_ordered_is_false.cs

示例5: Constructor_should_initialize_subject

        public void Constructor_should_initialize_subject()
        {
            var subject = new BulkMixedWriteOperation(_collectionNamespace, Enumerable.Empty<WriteRequest>(), _messageEncoderSettings);

            subject.CollectionNamespace.Should().Be(_collectionNamespace);
            subject.Requests.Should().BeEmpty();
            subject.MessageEncoderSettings.Should().BeEquivalentTo(_messageEncoderSettings);
        }
开发者ID:RainsSoft,项目名称:mongo-csharp-driver,代码行数:8,代码来源:BulkMixedWriteOperationTests.cs

示例6: When

 protected override void When()
 {
     var subject = new BulkMixedWriteOperation(DatabaseName, CollectionName, _requests)
     {
         IsOrdered = false
     };
     _result = ExecuteOperationAsync(subject).GetAwaiter().GetResult();
 }
开发者ID:Nakro,项目名称:mongo-csharp-driver,代码行数:8,代码来源:When_there_are_mixed_upserts_and_is_ordered_is_false.cs

示例7: MaxBatchCount_should_work

        public void MaxBatchCount_should_work()
        {
            var subject = new BulkMixedWriteOperation(_collectionNamespace, Enumerable.Empty<WriteRequest>(), _messageEncoderSettings);

            subject.MaxBatchCount.Should().Be(null);

            subject.MaxBatchCount = 20;

            subject.MaxBatchCount.Should().Be(20);
        }
开发者ID:RainsSoft,项目名称:mongo-csharp-driver,代码行数:10,代码来源:BulkMixedWriteOperationTests.cs

示例8: IsOrdered_should_work

        public void IsOrdered_should_work()
        {
            var subject = new BulkMixedWriteOperation(_collectionNamespace, Enumerable.Empty<WriteRequest>(), _messageEncoderSettings);

            subject.IsOrdered.Should().BeTrue();

            subject.IsOrdered = false;

            subject.IsOrdered.Should().BeFalse();
        }
开发者ID:RainsSoft,项目名称:mongo-csharp-driver,代码行数:10,代码来源:BulkMixedWriteOperationTests.cs

示例9: BypassDocumentValidation_should_work

        public void BypassDocumentValidation_should_work()
        {
            var subject = new BulkMixedWriteOperation(_collectionNamespace, Enumerable.Empty<WriteRequest>(), _messageEncoderSettings);

            subject.BypassDocumentValidation.Should().NotHaveValue();

            subject.BypassDocumentValidation = true;

            subject.BypassDocumentValidation.Should().BeTrue();
        }
开发者ID:HellDeveloper,项目名称:mongo-csharp-driver,代码行数:10,代码来源:BulkMixedWriteOperationTests.cs

示例10: Execute_with_a_very_large_upsert

        public void Execute_with_a_very_large_upsert(
            [Values(false, true)]
            bool async)
        {
            var smallDocument = new BsonDocument { { "_id", 7 }, { "x", "" } };
            var smallDocumentSize = smallDocument.ToBson().Length;
            var stringSize = 16 * 1024 * 1024 - smallDocumentSize;
            var largeString = new string('x', stringSize);

            var requests = new[] { new UpdateRequest(UpdateType.Update, new BsonDocument("_id", 7), new BsonDocument("$set", new BsonDocument("x", largeString))) { IsUpsert = true } };
            var subject = new BulkMixedWriteOperation(_collectionNamespace, requests, _messageEncoderSettings);

            var result = ExecuteOperation(subject, async);

            result.DeletedCount.Should().Be(0);
            result.InsertedCount.Should().Be(0);
            if (result.IsModifiedCountAvailable)
            {
                result.ModifiedCount.Should().Be(0);
            }
            result.MatchedCount.Should().Be(0);
            result.ProcessedRequests.Should().HaveCount(1);
            result.RequestCount.Should().Be(1);
            result.Upserts.Should().HaveCount(1);
            result.Upserts.Should().OnlyContain(x => x.Id == 7 && x.Index == 0);

            var list = ReadAllFromCollection(async);
            list.Should().HaveCount(7);
        }
开发者ID:RainsSoft,项目名称:mongo-csharp-driver,代码行数:29,代码来源:BulkMixedWriteOperationTests.cs

示例11: RenameHelperAsync

        private async Task RenameHelperAsync(BsonValue id, string newFilename, CancellationToken cancellationToken = default(CancellationToken))
        {
            var filesCollectionNamespace = GetFilesCollectionNamespace();
            var filter = new BsonDocument("_id", id);
            var update = new BsonDocument("$set", new BsonDocument("filename", newFilename));
            var requests = new[] { new UpdateRequest(UpdateType.Update, filter, update) };
            var messageEncoderSettings = GetMessageEncoderSettings();
            var updateOperation = new BulkMixedWriteOperation(filesCollectionNamespace, requests, messageEncoderSettings);

            using (var binding = await GetSingleServerReadWriteBindingAsync(cancellationToken).ConfigureAwait(false))
            {
                var result = await updateOperation.ExecuteAsync(binding, cancellationToken).ConfigureAwait(false);

                if (result.IsModifiedCountAvailable && result.ModifiedCount == 0)
                {
                    throw new GridFSFileNotFoundException(id);
                }
            }
        }
开发者ID:vienitdev,项目名称:mongo-csharp-driver,代码行数:19,代码来源:GridFSBucket.cs

示例12: ExecuteAsync_with_zero_requests_should_throw_an_exception

        public void ExecuteAsync_with_zero_requests_should_throw_an_exception()
        {
            var subject = new BulkMixedWriteOperation(_collectionNamespace, Enumerable.Empty<WriteRequest>(), _messageEncoderSettings);

            Func<Task> act = () => ExecuteOperationAsync(subject);

            act.ShouldThrow<InvalidOperationException>();
        }
开发者ID:fir3pho3nixx,项目名称:mongo-csharp-driver,代码行数:8,代码来源:BulkMixedWriteOperationTests.cs

示例13: Execute_with_more_updates_than_maxBatchCount

        public void Execute_with_more_updates_than_maxBatchCount(
            [Values(false, true)]
            bool async)
        {
            var requests = new[]
            {
                new UpdateRequest(UpdateType.Update, BsonDocument.Parse("{x: 1}"), BsonDocument.Parse("{$set: {a: 1}}")),
                new UpdateRequest(UpdateType.Update, BsonDocument.Parse("{x: 1}"), BsonDocument.Parse("{$set: {a: 2}}")),
                new UpdateRequest(UpdateType.Update, BsonDocument.Parse("{x: 1}"), BsonDocument.Parse("{$set: {a: 3}}")),
                new UpdateRequest(UpdateType.Update, BsonDocument.Parse("{x: 1}"), BsonDocument.Parse("{$set: {a: 4}}"))
            };
            var subject = new BulkMixedWriteOperation(_collectionNamespace, requests, _messageEncoderSettings)
            {
                MaxBatchCount = 3
            };

            var result = ExecuteOperation(subject, async);

            result.DeletedCount.Should().Be(0);
            result.InsertedCount.Should().Be(0);
            if (result.IsModifiedCountAvailable)
            {
                result.ModifiedCount.Should().Be(4);
            }
            result.MatchedCount.Should().Be(4);
            result.ProcessedRequests.Should().HaveCount(4);
            result.RequestCount.Should().Be(4);
            result.Upserts.Should().BeEmpty();

            var list = ReadAllFromCollection(async);
            list.Should().HaveCount(6);
        }
开发者ID:RainsSoft,项目名称:mongo-csharp-driver,代码行数:32,代码来源:BulkMixedWriteOperationTests.cs

示例14: Execute_with_an_empty_update_document_should_throw

        public void Execute_with_an_empty_update_document_should_throw(
            [Values(false, true)]
            bool async)
        {
            var requests = new[] { new UpdateRequest(UpdateType.Update, BsonDocument.Parse("{x: 1}"), new BsonDocument()) };
            var subject = new BulkMixedWriteOperation(_collectionNamespace, requests, _messageEncoderSettings);

            Action act = () => ExecuteOperation(subject, async);
            act.ShouldThrow<BsonSerializationException>();
        }
开发者ID:RainsSoft,项目名称:mongo-csharp-driver,代码行数:10,代码来源:BulkMixedWriteOperationTests.cs

示例15: Execute_with_one_update_against_a_matching_document

        public void Execute_with_one_update_against_a_matching_document(
            [Values(false, true)]
            bool async)
        {
            var requests = new[] { new UpdateRequest(UpdateType.Update, BsonDocument.Parse("{x: 1}"), BsonDocument.Parse("{$set: {a: 1}}")) };
            var subject = new BulkMixedWriteOperation(_collectionNamespace, requests, _messageEncoderSettings);

            var result = ExecuteOperation(subject, async);

            result.DeletedCount.Should().Be(0);
            result.InsertedCount.Should().Be(0);
            if (result.IsModifiedCountAvailable)
            {
                result.ModifiedCount.Should().Be(1);
            }
            result.MatchedCount.Should().Be(1); // I don't understand this...
            result.ProcessedRequests.Should().HaveCount(1);
            result.RequestCount.Should().Be(1);
            result.Upserts.Should().BeEmpty();

            var list = ReadAllFromCollection(async);
            list.Should().HaveCount(6);
        }
开发者ID:RainsSoft,项目名称:mongo-csharp-driver,代码行数:23,代码来源:BulkMixedWriteOperationTests.cs


注:本文中的BulkMixedWriteOperation类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。