class Program
{
static void Main(string[] args)
{
Run().Wait();
}
private static async Task Run()
{
var client = new MongoClient("mongodb://localhost:27016");
try
{
var database = client.GetDatabase("testv2");
var customers = database.GetCollection<Customer>("customer");
var nextId = 563627090084241408;
var nextId2 = 563627090084241409;
customers.InsertOneAsync(new Customer { Name = "Dave", Id = nextId }).Wait();
customers.InsertOneAsync(new Customer { Name = "Steve", Id = nextId2 }).Wait();
var list = await customers.Find(x => x.Name == "Jill")
.ToListAsync();
foreach (var person in list)
{
Console.WriteLine(person.Name);
}
}
catch (Exception)
{
throw;
}
}
}
public class Customer
{
public long Id { get; set; }
public string Name { get; set; }
}