private async Task splitter(string collectionname) { List <int> codes = MongoTools.distinct(collectionname, db, "stationCode"); IMongoCollection <BsonDocument> variableCollection = db.GetCollection <BsonDocument>(collectionname); FindOptions <BsonDocument> options = new FindOptions <BsonDocument> { BatchSize = 1000, NoCursorTimeout = false }; foreach (int stationcode in codes) { //get or make a station collection IMongoCollection <BsonDocument> stationVariableCollection = db.GetCollection <BsonDocument>("s_" + stationcode + "_" + collectionname); var builder = Builders <BsonDocument> .Filter; var filter = builder.Eq("stationCode", stationcode); //find in the variable collection using (IAsyncCursor <BsonDocument> cursor = await variableCollection.FindAsync(filter, options)) { while (await cursor.MoveNextAsync()) { IEnumerable <BsonDocument> documents = cursor.Current; //insert into the station collection await stationVariableCollection.InsertManyAsync(documents); } } } }