Skip to content

Instantly share code, notes, and snippets.

@feanz
Last active November 30, 2017 18:00
Show Gist options
  • Save feanz/4647bcb3d986e20c8e17 to your computer and use it in GitHub Desktop.
Save feanz/4647bcb3d986e20c8e17 to your computer and use it in GitHub Desktop.
Example issue with mongo client version 2 beta
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; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment