本文整理汇总了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);
}
示例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);
}