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

authentication - Mongodb revoke acccess to connect test database -

c - getting error: cannot take the address of an rvalue of type 'int' -

How to merge four videos on one screen with ffmpeg -