Iam trying to find a good way to make a method that retrieve data from mongodb with the newest driver. All the guides I found are or old driver version or I cant make it work. I tried to make it with the tutorial at the mongodb site but it's just printing the results and I need to make a method that returns a list with my data. Can anyone show me a method that works?
public async Task<List<BsonDocument>> FooAsync()
{
var Client = new MongoClient();
var DB = Client.GetDatabase("DB");
var collection = DB.GetCollection<BsonDocument>("Users");
var a = await collection.Find(new BsonDocument()).ToListAsnyc();
return (a);
}
public static List<BsonDocument> aba()
{
var task = FooAsync();
var result = task.Result;
return (result);
}