Skip to content
This repository has been archived by the owner on Feb 22, 2020. It is now read-only.

Latest commit

 

History

History
41 lines (32 loc) · 1.71 KB

README.md

File metadata and controls

41 lines (32 loc) · 1.71 KB

Logo Project Description

An easy to use library to use MongoDB with .NET. It implements a Repository pattern on top of Official MongoDB C# driver. This project is now available as a NuGet package for your convenience. 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:

// The Entity base-class is provided by MongoRepository
// for all entities you want to use in MongoDb
public class Customer : Entity 
{
        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);
        }
}

Productivity Visual Studio add-in for C#, VB.NET, XML, XAML, ASP.NET and more