示例#1
0
        /// <summary>
        /// Creates a new MongoDbSet using the connection string in the configuration that matches the specified connection name.
        /// </summary>
        /// <param name="connectionName">The name of the connection string stored in the configuration.</param>
        public MongoDbSet(string connectionName)
        {
            var mongoUrl = MongoDbUtility.GetMongoUrlFromConfig(connectionName);

            if (mongoUrl == null)
            {
                throw new MongoConfigurationException("No connection string found with the name \'" + connectionName + "\'");
            }

            SetDatabase(MongoDbUtility.GetDatabase(mongoUrl));
        }
 public MongoDbContext(IMongoDbContextOptions options)
 {
     Database = MongoDbUtility.GetDatabase(options);
     InitialiseDbSets();
 }
 public MongoDbContext(string connectionString, string databaseName)
 {
     Database = MongoDbUtility.GetDatabase(connectionString, databaseName);
     InitialiseDbSets();
 }
示例#4
0
 /// <summary>
 /// Creates a new MongoDbSet using the specified connection string and database combination.
 /// </summary>
 /// <param name="connectionString">The connection string to the server</param>
 /// <param name="databaseName">The database name on the server</param>
 public MongoDbSet(string connectionString, string databaseName)
 {
     SetDatabase(MongoDbUtility.GetDatabase(connectionString, databaseName));
 }