c# - How to get a certain mongodb document value from each document as a list of strings? -


in every mongodb document in collection have "project_name" field string. want retrieve list<string> object each of distinct values (hence group in example below), cannot seem figure out. have looked projections , cannot find example works me.

this closest have gotten:

public list<string> getprojectnames1() {     var collection = _database.getcollection<bsondocument>(vehiclescollection);      var aggregation = collection.aggregate()         .group(new bsondocument { { "_id", "$project_name" } })         .tolist()         .select(i => i.getvalue("_id").tostring())         .tolist();      return aggregation; } 

i feel there better way though, using projections in way.


Comments

Popular posts from this blog

Receive udp packets in android gstreamer -

php - Extract Text from HTTP referer -

matplotlib - PYTHON: Annotate boxes disapear dependant on range -