Is my way of using MongoDB C# driver FindAsync flawed?
stackoverflow.com › questions › 65790624Jan 19, 2021 · My goal was to search for entries in my MongoDB via FindAsync. Here is my code for that: public async Task<List<T>> SearchDocAsync<T, U> (string collection, string findFieldName, U findValue) { var _collection = db.GetCollection<T> (collection); var filter = Builders<T>.Filter.Eq (findFieldName, findValue); var result = await (_collection.FindAsync (filter).Result.ToListAsync ()); return result; }
MongoDB C#/.NET Driver — MongoDB Drivers
www.mongodb.com › docs › driversConnect to a MongoDB Server on Your Local Machine If you need to run a MongoDB server on your local machine for development purposes instead of using an Atlas cluster, you need to complete the following: Download the Community or Enterprise version of MongoDB Server. Install and configure MongoDB Server. Start the server. Important