This library simplifies access to mongodb by abstracting away the C# mongodb driver and providing some additional features on top of it. The API is clean and intuitive resulting in less lines of code that is more readable/ human friendly than driver code.
- Don't have to deal with
ObjectIds
,BsonDocuments
& magic strings unless you want to. - Built-in support for
One-To-One
,One-To-Many
andMany-To-Many
relationships. - Async only API for scalable application development.
- Query data using LINQ, lambda expressions, filters and aggregation pipelines.
- Sorting, paging and projecting is made convenient.
- Simple data migration framework similar to EntityFramework.
- Programatically define indexes.
- Full text search (including fuzzy matching) with text indexes.
- Multi-document transaction support.
- Multiple database support.
- Easy bulk operations.
- Easy Change-stream support.
- GeoSpatial search.
- Stream files in chunks to and from mongodb (GridFS alternative).
- Project types supported: .Net Standard 2.0 (.Net Core 2.0 & .Net Framework 4.6.1 or higher)
//Initialize database connection
await DB.InitAsync("bookshop","localhost");
//Create and persist an entity
var book = new Book { Title = "The Power Of Now" };
await book.SaveAsync();
//Embed as document
var dickens = new Author { Name = "Charles Dickens" };
book.Author = dickens.ToDocument();
await book.SaveAsync();
//One-To-One relationship
var hemmingway = new Author { Name = "Ernest Hemmingway" };
await hemmingway.SaveAsync();
book.MainAuthor = hemmingway;
await book.SaveAsync();
//One-To-Many relationship
var tolle = new Author { Name = "Eckhart Tolle" };
await tolle.SaveAsync();
await book.Authors.AddAsync(tolle);
//Many-To-Many relationship
var genre = new Genre { Name = "Self Help" };
await genre.SaveAsync();
await book.AllGenres.AddAsync(genre);
await genre.AllBooks.AddAsync(book);
//Queries
var author = await DB.Find<Author>().OneAsync("ID");
var authors = await DB.Find<Author>().ManyAsync(a => a.Publisher == "Harper Collins");
var eckhart = await DB.Queryable<Author>()
.Where(a => a.Name.Contains("Eckhart"))
SingleOrDefaultAsync();
var powerofnow = await genre.AllBooks.ChildrenQueryable()
.Where(b => b.Title.Contains("Power"))
.SingleOrDefaultAsync();
var selfhelp = await book.AllGenres.ChildrenQueryable().FirstAsync();
//Delete
await book.MainAuthor.DeleteAsync();
await book.AllAuthors.DeleteAllAsync();
await book.DeleteAsync();
await DB.DeleteAsync<Genre>(genre.ID);
- .net core console project
- asp.net core web-api project
- a collection of gists
- integration/unit test project
- solutions to stackoverflow questions
if this library has made your life easier and you'd like to express your gratitude, you can donate a couple of bucks via paypal by clicking the button below: