To get the records from MongoDB using Asp.net.
using MongoDB.Bson;
using MongoDB.Driver;
static MongoClient client = new MongoClient("mongodb://localhost:27017"); //Set the connection
string
static IMongoDatabase db =
client.GetDatabase("test"); //Database
name
public void List()
{
IMongoCollection<BsonDocument> collection = db.GetCollection<BsonDocument>("user"); //table name
var filter = Builders<BsonDocument>.Filter.Empty; //It behaves like select * from user
var
res = collection.Find(filter).ToList();
}
No comments:
Post a Comment