I am trying to get individual values ββfrom a field in MongoDB. I have real syntax issues. Using mongoshell, this is relatively easy to do, this is the query that I run:
db.cmstest.distinct("categories")
This query returns an array of strings with all individual values.
Now I'm trying to get the syntax correctly using the latest official MongoDB drivers, but not for success. This is my code that was unsuccessful:
var categoriesList = await blogContext.Articles.DistinctAsync<List<string>>("categories", "");
Note: List<string>
categories.
Can anyone help shed some light? I tried to look both in the documentation and on the Internet and did not find much.
Thanks in advance.
source share