Skip to content
atheken edited this page Aug 13, 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.
  • Fluent-like interaction with Mongo collections.
  • LINQ-to-Mongo

Getting started with NoRMcan be as easy as this:

    //open collection
    var coll = (new MongoServer()).GetDatabase("benchmark")
                      .GetCollection<GeneralDTO>("test");
    //create a new object to be added to the collection
    var obj = new GeneralDTO();
    obj._id = BSONOID.NewOID();
    obj.Title = "Hello World";
    //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.

Flyweight — 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. Flyweight helps us to have the best of both worlds.

Clone this wiki locally