Skip to content

Instantly share code, notes, and snippets.

@feanz
Created February 6, 2015 16:24
Show Gist options
  • Save feanz/b411d4e5a1049d8b8803 to your computer and use it in GitHub Desktop.
Save feanz/b411d4e5a1049d8b8803 to your computer and use it in GitHub Desktop.
Example issue with mongo client version 1.
public class program
{
static void Main(string[] args)
{
var client = new MongoClient("mongodb://localhost:27016");
try
{
var server = client.GetServer();
var database = server.GetDatabase("testv1");
var customers = database.GetCollection<Customer>("customer");
var nextId = 563627090084241408;
var nextId2 = 563627090084241409;
customers.Insert(new Customer { Name = "Dave", Id = nextId });
customers.Insert(new Customer { Name = "Steve", Id = nextId2 });
var query = Query<Customer>.EQ(u => u.Name, "Dave");
var list = customers.FindAs<Customer>(query);
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