Beispiel #1
0
        /// <summary>
        /// Creates the default configuration to read from a given mongo db collection for ALL Keys  additionally applying a filter to fetch records. Keys can be OVERWRITTEN if multiple records are found for the filter.
        /// </summary>
        /// <param name="connectionString">The connection string.</param>
        /// <param name="databaseName">Name of the database.</param>
        /// <param name="collectionName">Name of the collection.</param>
        /// <param name="keyToQuery">The key to query.</param>
        /// <param name="valueToMatch">The value to match.</param>
        /// <returns>MongoDbConfigOptions.</returns>
        public static MongoDbConfigOptions GetOptionsForAllKeysFilteredDocuments(string connectionString, string databaseName,
                                                                                 string collectionName, string keyToQuery, object valueToMatch)
        {
            var instance = new MongoDbConfigOptions(connectionString, databaseName, collectionName)
            {
                QueryInFilteredMode = true,
                KeyToQuery          = keyToQuery,
                ValueToMatch        = valueToMatch
            };

            return(instance);
        }
Beispiel #2
0
        private static void ConfigureMongoConfiguration(HostBuilderContext arg1, IConfigurationBuilder configurationBuilder)
        {
            configurationBuilder.AddMongoDbConfiguration(MongoDbConfigOptions.GetOptionsForAllKeysAllDocuments(
                                                             @"mongodb://<CONNECTION_STRING>",
                                                             "myconfigdb", "settings"));

            //configurationBuilder.AddMongoDbConfiguration(MongoDbConfigOptions.GetOptionsForDefinedKeysAllDocuments(
            //    @"mongodb://<CONNECTION_STRING>",
            //    "myconfigdb", "settings","key2","key3"));

            //configurationBuilder.AddMongoDbConfiguration(MongoDbConfigOptions.GetOptionsForAllKeysFilteredDocuments(
            //    @"mongodb://<CONNECTION_STRING>",
            //    "myconfigdb", "settings", "environment", "qa"));
            configurationBuilder.AddMongoDbConfiguration(MongoDbConfigOptions.GetOptionsForDefinedKeysFilteredDocument(
                                                             @"mongodb://<CONNECTION_STRING>",
                                                             "myconfigdb", "settings", "environment", "dev", "key1", "key2", "key9"));
        }