Project Description
An easy to use library to use MongoDB with .NET. (Implements Repository pattern on top of Official MongoDB C# driver). This project is now available as a
NuGet package for your convenience; binaries are still available in
the downloads section. If you're new to NuGet,
check it out; it's painless, easy and fast. You can find this project by
searching for MongoRepository in NuGet (or
simply clicking here).
Check the
documentation for a step-by-step example and more advanced usage.
Example:
public class Customer : Entity
// The Entity base-class is provided by MongoRepository
// for all entities you want to use in MongoDb
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
public class CustomerRepoTest
{
public void Test()
{
var repo = new MongoRepository<Customer>();
// adding new entity
var newCustomer = new Customer {
FirstName = "Steve",
LastName = "Cornell"
};
repo.Add(newCustomer);
// searching
var result = repo.Where(c => c.FirstName == "Steve");
// updating
newCustomer.LastName = "Castle";
repo.Update(newCustomer);
}
}