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


C# CreateCollectionOperation.ExecuteAsync方法代码示例

本文整理汇总了C#中CreateCollectionOperation.ExecuteAsync方法的典型用法代码示例。如果您正苦于以下问题:C# CreateCollectionOperation.ExecuteAsync方法的具体用法?C# CreateCollectionOperation.ExecuteAsync怎么用?C# CreateCollectionOperation.ExecuteAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CreateCollectionOperation的用法示例。


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

示例1: ExecuteOperation

 private BsonDocument ExecuteOperation(CreateCollectionOperation subject, IWriteBinding binding, bool async)
 {
     if (async)
     {
         return subject.ExecuteAsync(binding, CancellationToken.None).GetAwaiter().GetResult();
     }
     else
     {
         return subject.Execute(binding, CancellationToken.None);
     }
 }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:11,代码来源:CreateCollectionOperationTests.cs

示例2: ExecuteAsync_should_create_collection_when_UsePowerOf2Sizes_is_set

        public async Task ExecuteAsync_should_create_collection_when_UsePowerOf2Sizes_is_set(
            [Values(false, true)]
            bool usePowerOf2Sizes)
        {
            var subject = new CreateCollectionOperation(_collectionNamespace, _messageEncoderSettings)
            {
                UsePowerOf2Sizes = usePowerOf2Sizes
            };

            using (var binding = CoreTestConfiguration.GetReadWriteBinding())
            {
                var result = await subject.ExecuteAsync(binding, CancellationToken.None);

                result["ok"].ToBoolean().Should().BeTrue();

                var stats = await GetCollectionStatsAsync(binding);
                stats["ns"].ToString().Should().Be(_collectionNamespace.FullName);
                stats["userFlags"].ToInt32().Should().Be(usePowerOf2Sizes ? 1 : 0);
            }
        }
开发者ID:fir3pho3nixx,项目名称:mongo-csharp-driver,代码行数:20,代码来源:CreateCollectionOperationTests.cs

示例3: EnsureCollectionExists

 private void EnsureCollectionExists(IWriteBinding binding, CollectionNamespace collectionNamespace)
 {
     try
     {
         var operation = new CreateCollectionOperation(collectionNamespace, _messageEncoderSettings);
         operation.ExecuteAsync(binding, CancellationToken.None).GetAwaiter().GetResult();
     }
     catch (MongoCommandException ex)
     {
         if (ex.Message == "Command create failed: collection already exists.")
         {
             return;
         }
         throw;
     }
 }
开发者ID:fir3pho3nixx,项目名称:mongo-csharp-driver,代码行数:16,代码来源:RenameCollectionOperationTests.cs

示例4: ExecuteAsync_should_create_collection_when_MaxSize_is_set

        public async Task ExecuteAsync_should_create_collection_when_MaxSize_is_set()
        {
            var maxSize = 10000L;
            var subject = new CreateCollectionOperation(_collectionNamespace, _messageEncoderSettings)
            {
                Capped = true,
                MaxSize = maxSize
            };

            using (var binding = CoreTestConfiguration.GetReadWriteBinding())
            {
                var result = await subject.ExecuteAsync(binding, CancellationToken.None);

                result["ok"].ToBoolean().Should().BeTrue();

                var stats = await GetCollectionStatsAsync(binding);
                stats["ns"].ToString().Should().Be(_collectionNamespace.FullName);
                stats["capped"].ToBoolean().Should().BeTrue();
                // TODO: not sure how to verify that the maxSize took effect
            }
        }
开发者ID:fir3pho3nixx,项目名称:mongo-csharp-driver,代码行数:21,代码来源:CreateCollectionOperationTests.cs

示例5: ExecuteAsync_should_create_collection_when_MaxDocuments_is_set

        public async Task ExecuteAsync_should_create_collection_when_MaxDocuments_is_set()
        {
            var maxDocuments = 123L;
            var subject = new CreateCollectionOperation(_collectionNamespace, _messageEncoderSettings)
            {
                Capped = true,
                MaxSize = 10000L,
                MaxDocuments = maxDocuments
            };

            using (var binding = CoreTestConfiguration.GetReadWriteBinding())
            {
                var result = await subject.ExecuteAsync(binding, CancellationToken.None);

                result["ok"].ToBoolean().Should().BeTrue();

                var stats = await GetCollectionStatsAsync(binding);
                stats["ns"].ToString().Should().Be(_collectionNamespace.FullName);
                stats["capped"].ToBoolean().Should().BeTrue();
                stats["max"].ToInt64().Should().Be(maxDocuments);
            }
        }
开发者ID:fir3pho3nixx,项目名称:mongo-csharp-driver,代码行数:22,代码来源:CreateCollectionOperationTests.cs

示例6: ExecuteAsync_should_create_collection_when_Capped_is_set

        public async Task ExecuteAsync_should_create_collection_when_Capped_is_set(
            [Values(false, true)]
            bool capped)
        {
            var maxSize = capped ? (long?)10000 : null;
            var subject = new CreateCollectionOperation(_collectionNamespace, _messageEncoderSettings)
            {
                Capped = capped,
                MaxSize = maxSize
            };

            using (var binding = CoreTestConfiguration.GetReadWriteBinding())
            {
                var result = await subject.ExecuteAsync(binding, CancellationToken.None);

                result["ok"].ToBoolean().Should().BeTrue();

                var stats = await GetCollectionStatsAsync(binding);
                stats["ns"].ToString().Should().Be(_collectionNamespace.FullName);
                stats.GetValue("capped", false).ToBoolean().Should().Be(capped);
            }
        }
开发者ID:fir3pho3nixx,项目名称:mongo-csharp-driver,代码行数:22,代码来源:CreateCollectionOperationTests.cs

示例7: ExecuteAsync_should_create_collection_when_AutoIndexId_is_set

        public async Task ExecuteAsync_should_create_collection_when_AutoIndexId_is_set(
            [Values(false, true)]
            bool autoIndexId)
        {
            var subject = new CreateCollectionOperation(_collectionNamespace, _messageEncoderSettings)
            {
                AutoIndexId = autoIndexId
            };

            using (var binding = CoreTestConfiguration.GetReadWriteBinding())
            {
                var result = await subject.ExecuteAsync(binding, CancellationToken.None);

                result["ok"].ToBoolean().Should().BeTrue();

                var listIndexesOperation = new ListIndexesOperation(_collectionNamespace, _messageEncoderSettings);
                var cursor = await listIndexesOperation.ExecuteAsync(binding, CancellationToken.None);
                var indexes = await cursor.ToListAsync();

                indexes.Count.Should().Be(autoIndexId ? 1 : 0);
            }
        }
开发者ID:fir3pho3nixx,项目名称:mongo-csharp-driver,代码行数:22,代码来源:CreateCollectionOperationTests.cs

示例8: ExecuteAsync_should_create_collection

        public async Task ExecuteAsync_should_create_collection()
        {
            var subject = new CreateCollectionOperation(_collectionNamespace, _messageEncoderSettings);

            using (var binding = CoreTestConfiguration.GetReadWriteBinding())
            {
                var result = await subject.ExecuteAsync(binding, CancellationToken.None);

                result["ok"].ToBoolean().Should().BeTrue();

                var stats = await GetCollectionStatsAsync(binding);
                stats["ns"].ToString().Should().Be(_collectionNamespace.FullName);
            }
        }
开发者ID:fir3pho3nixx,项目名称:mongo-csharp-driver,代码行数:14,代码来源:CreateCollectionOperationTests.cs


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