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


C# FindOperation.CreateFindCommandOperation方法代码示例

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


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

示例1: CreateFindCommandOperation_should_return_expected_result_when_modifiers_are_provided

        public void CreateFindCommandOperation_should_return_expected_result_when_modifiers_are_provided()
        {
            var subject = new FindOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings)
            {
                ReadConcern = ReadConcern.Majority
            };
            subject.Modifiers = new BsonDocument
            {
                { "$hint", "x_1" },
                { "$max", new BsonDocument("max", 1) },
                { "$maxScan", 1 },
                { "$maxTimeMS", 2000 },
                { "$min", new BsonDocument("min", 1) },
                { "$orderby", new BsonDocument("sort", 1) },
                { "$showDiskLoc", true },
                { "$snapshot", true }
            };

            var result = subject.CreateFindCommandOperation();

            result.Hint.Should().Be(subject.Modifiers["$hint"]);
            result.Max.Should().Be(subject.Modifiers["$max"].AsBsonDocument);
            result.MaxScan.Should().Be(subject.Modifiers["$maxScan"].AsInt32);
            result.MaxTime.Should().Be(TimeSpan.FromMilliseconds(subject.Modifiers["$maxTimeMS"].AsInt32));
            result.Min.Should().Be(subject.Modifiers["$min"].AsBsonDocument);
            result.ReadConcern.Should().Be(subject.ReadConcern);
            result.ShowRecordId.Should().Be(subject.Modifiers["$showDiskLoc"].AsBoolean);
            result.Snapshot.Should().Be(subject.Modifiers["$snapshot"].AsBoolean);
            result.Sort.Should().Be(subject.Modifiers["$orderby"].AsBsonDocument);
        }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:30,代码来源:FindOperationTests.cs

示例2: CreateFindCommandOperation_should_return_expected_result

        public void CreateFindCommandOperation_should_return_expected_result()
        {
            var subject = new FindOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings);
            subject.AllowPartialResults = true;
            subject.BatchSize = 1;
            subject.Comment = "comment";
            subject.CursorType = CursorType.Tailable;
            subject.Filter = new BsonDocument("filter", 1);
            subject.FirstBatchSize = 2;
            subject.Hint = "x_1";
            subject.Limit = 3;
            subject.Max = new BsonDocument("max", 1);
            subject.MaxScan = 4;
            subject.MaxAwaitTime = TimeSpan.FromSeconds(2);
            subject.MaxTime = TimeSpan.FromSeconds(1);
            subject.Min = new BsonDocument("min", 1);
            subject.NoCursorTimeout = true;
            subject.OplogReplay = true;
            subject.Projection = new BsonDocument("projection", 1);
            subject.ReadConcern = ReadConcern.Local;
            subject.ReturnKey = true;
            subject.ShowRecordId = true;
            subject.SingleBatch = true;
            subject.Skip = 6;
            subject.Snapshot = true;
            subject.Sort = new BsonDocument("sort", 1);

            var result = subject.CreateFindCommandOperation();

            result.AllowPartialResults.Should().Be(subject.AllowPartialResults);
            result.BatchSize.Should().Be(subject.BatchSize);
            result.CollectionNamespace.Should().Be(subject.CollectionNamespace);
            result.Comment.Should().Be(subject.Comment);
            result.CursorType.Should().Be(subject.CursorType);
            result.Filter.Should().Be(subject.Filter);
            result.FirstBatchSize.Should().Be(subject.FirstBatchSize);
            result.Hint.Should().Be(subject.Hint);
            result.Limit.Should().Be(subject.Limit);
            result.Max.Should().Be(subject.Max);
            result.MaxScan.Should().Be(subject.MaxScan);
            result.MaxAwaitTime.Should().Be(subject.MaxAwaitTime);
            result.MaxTime.Should().Be(subject.MaxTime);
            result.MessageEncoderSettings.Should().BeSameAs(subject.MessageEncoderSettings);
            result.Min.Should().Be(subject.Min);
            result.NoCursorTimeout.Should().Be(subject.NoCursorTimeout);
            result.OplogReplay.Should().Be(subject.OplogReplay);
            result.Projection.Should().Be(subject.Projection);
            result.ReadConcern.Should().Be(subject.ReadConcern);
            result.ResultSerializer.Should().Be(subject.ResultSerializer);
            result.ReturnKey.Should().Be(subject.ReturnKey);
            result.ShowRecordId.Should().Be(subject.ShowRecordId);
            result.SingleBatch.Should().Be(subject.SingleBatch);
            result.Skip.Should().Be(subject.Skip);
            result.Snapshot.Should().Be(subject.Snapshot);
            result.Sort.Should().Be(subject.Sort);
        }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:56,代码来源:FindOperationTests.cs


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