Here is my code:
using MongoDB.Bson;
using MongoDB.Driver;
public List<Teacher> GetTeachersFromMongoDB()
{
client = new MongoClient();
database = client.GetDatabase("SchoolManagement");
var collection = database.GetCollection<BsonDocument>("ListTeachers");
var document = collection.Find(new BsonDocument()).ToList();
var cursor = collection.Find(new BsonDocument()).ToCursor();
return teachers;
}
And i want to do something to return value type List for this function. Please help me!!! Thank you :)
I assume you have a Teacher object, so I think you should use
var collection = database.GetCollection<Teacher>("ListTeachers");
instead of
var collection = database.GetCollection<BsonDocument>("ListTeachers");
And I don't get, where your return value comes from, but if you return 'document' it should work
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.