Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using MongoDB.Bson;
- using MongoDB.Bson.IO;
- using MongoDB.Bson.Serialization;
- using MongoDB.Driver;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace M101DotNet
- {
- class Program
- {
- static void Main(string[] args)
- {
- MainAsync(args).GetAwaiter().GetResult();
- Console.WriteLine("Press enter");
- Console.ReadLine();
- }
- static async Task MainAsync(string[] args)
- {
- var client = new MongoClient();
- var db = client.GetDatabase("Phucdb");
- var col = db.GetCollection<BsonDocument>("users");
- using (var cursor = await col.Find(new BsonDocument()).ToCursorAsync())
- {
- while (await cursor.MoveNextAsync())
- {
- foreach (var doc in cursor.Current)
- {
- Console.WriteLine(doc);
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement