Skip to content
atheken edited this page Oct 15, 2010 · 26 revisions

NoRM is a .Net library for connecting to the document-oriented database, MongoDB.

General goals include:

  • Strongly-typed interaction when querying and updating collections.
  • Improved interface to send common Mongo commands (creating indices, getting all the existing dbs and collections, etc.).
  • Ultra-fast de/serialization of BSON to .Net CLR types and back.
  • LINQ-to-Mongo
  • Support for Mono

Getting started with NoRM can be as easy as this:

  //connString is a URI to the database with the credentials you need.
    var coll = (new Mongo(connString)).GetCollection<Product>();
    //create a new object to be added to the collection
    var obj = new Product();
    obj._id = ObjectId.NewObjectID();
    obj.Title = "Shoes";
    //save the object
    coll.Insert(obj);
    //find the object
    var obj2 = coll.FindOne(new { _id = obj._id}).First();

We’ve made some important decisions that you should be aware of:

BSON Serializer — Just as BSON is the core of MongoDB, this is the core of NoRM. In order to provide a powerful serializer, we have rules about what you can & cannot serialize, reading this page will save you a lot of time in debugging.

Expando — Because we want to do as much as possible in a strongly-typed way, NoRM is built around the concept of using class definitions as document templates. We realize there will be times when it will be favorable to have arbitrary properties for a given entity. Expando helps us to have the best of both worlds.

Even more useful information:

Configuration — NoRM provides powerful Configuration options so that you can deal with your POCO using more “.Net-like” naming conventions, but store them using “MongoDB-like” naming conventions. Ignoring properties or specifying a different property to be used as the _id is also possible.

Examples provides snippets that can be used to accomplish specific tasks with NoRM.

Interested in contributing but having a hard time getting tests to pass? The Passing Tests page will help you get things setup.