コード例 #1
0
        private FindOperation <TResult> CreateAggregateToCollectionFindOperation <TResult>(BsonDocument outStage, IBsonSerializer <TResult> resultSerializer, AggregateOptions options)
        {
            CollectionNamespace outputCollectionNamespace;
            var stageName = outStage.GetElement(0).Name;

            switch (stageName)
            {
            case "$out":
            {
                var outValue = outStage[0];
                DatabaseNamespace outputDatabaseNamespace;
                string            outputCollectionName;
                if (outValue.IsString)
                {
                    outputDatabaseNamespace = _databaseNamespace;
                    outputCollectionName    = outValue.AsString;
                }
                else
                {
                    outputDatabaseNamespace = new DatabaseNamespace(outValue["db"].AsString);
                    outputCollectionName    = outValue["coll"].AsString;
                }
                outputCollectionNamespace = new CollectionNamespace(outputDatabaseNamespace, outputCollectionName);
            }
            break;

            case "$merge":
            {
                var mergeArguments = outStage[0].AsBsonDocument;
                DatabaseNamespace outputDatabaseNamespace;
                string            outputCollectionName;
                var into = mergeArguments["into"];
                if (into.IsString)
                {
                    outputDatabaseNamespace = _databaseNamespace;
                    outputCollectionName    = into.AsString;
                }
                else
                {
                    outputDatabaseNamespace = new DatabaseNamespace(into["db"].AsString);
                    outputCollectionName    = into["coll"].AsString;
                }
                outputCollectionNamespace = new CollectionNamespace(outputDatabaseNamespace, outputCollectionName);
            }
            break;

            default:
                throw new ArgumentException($"Unexpected stage name: {stageName}.");
            }

            // because auto encryption is not supported for non-collection commands.
            // So, an error will be thrown in the previous CreateAggregateToCollectionOperation step.
            // However, since we've added encryption configuration for CreateAggregateToCollectionOperation operation,
            // it's not superfluous to also add it here
            var messageEncoderSettings = GetMessageEncoderSettings();

            return(new FindOperation <TResult>(outputCollectionNamespace, resultSerializer, messageEncoderSettings)
            {
                BatchSize = options.BatchSize,
                Collation = options.Collation,
                MaxTime = options.MaxTime,
                ReadConcern = _settings.ReadConcern,
                RetryRequested = _client.Settings.RetryReads
            });
        }
コード例 #2
0
 public void IsValid_should_return_the_correct_result(string name, bool valid)
 {
     DatabaseNamespace.IsValid(name).Should().Be(valid);
 }
コード例 #3
0
        public void DatabaseName_should_report_the_provided_database_name()
        {
            var subject = new DatabaseNamespace("test");

            subject.DatabaseName.Should().Be("test");
        }
コード例 #4
0
        public void ToString_should_return_the_name()
        {
            var subject = new DatabaseNamespace("test");

            subject.ToString().Should().Be("test");
        }
コード例 #5
0
 public void DatabaseUsingTestSetUp()
 {
     _databaseNamespace = new DatabaseNamespace(GetDatabaseName());
 }
コード例 #6
0
 public CollectionNamespace(DatabaseNamespace databaseNamespace, string collectionName)
 {
     _databaseNamespace = Ensure.IsNotNull(databaseNamespace, "databaseNamespace");
     _collectionName    = Ensure.That(collectionName, IsValid, "collectionName", "Collection names must be non-empty and not contain the null character.");
 }
コード例 #7
0
ファイル: CollectionNamespace.cs プロジェクト: LJM74520/nice
 /// <summary>
 /// Initializes a new instance of the <see cref="CollectionNamespace"/> class.
 /// </summary>
 /// <param name="databaseNamespace">The database namespace.</param>
 /// <param name="collectionName">The name of the collection.</param>
 public CollectionNamespace(DatabaseNamespace databaseNamespace, string collectionName)
 {
     _databaseNamespace = Ensure.IsNotNull(databaseNamespace, nameof(databaseNamespace));
     _collectionName    = Ensure.That(collectionName, IsValid, nameof(collectionName), "Collection names must be non-empty and not contain the null character.");
     _fullName          = _databaseNamespace.DatabaseName + "." + _collectionName;
 }
コード例 #8
0
 public void SuiteConfigurationSetUp()
 {
     __connectionString  = GetConnectionString();
     __databaseNamespace = GetDatabaseNamespace();
 }