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

RobThree/MongoRepository

Folders and files

NameName
Last commit message
Last commit date

Latest commit

42d6559 · Jan 13, 2020
Jan 13, 2020
Jan 13, 2020
Mar 31, 2016
Jan 13, 2020
Feb 12, 2015
Mar 31, 2016
Jan 13, 2020
Feb 12, 2015
Jan 13, 2020
Nov 20, 2015
Feb 12, 2015
Nov 20, 2015

Repository files navigation

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