NoRM MongoConfiguration

Posted by user365836 on Stack Overflow See other posts from Stack Overflow or by user365836
Published on 2010-06-13T19:17:58Z Indexed on 2010/06/13 19:22 UTC
Read the original article Hit count: 484

Filed under:
|

Something is wrong with my MongoConfiguration I think, I read the following on NoRM's google group:

On Mar 22, 3:14 am, Andrew Theken wrote:
It can easily live in the object:

public class POCO{

//implicitly runs one time.
static POCO(){
  MongoConfiguration.Initialize(cfg=> cfg.For<POCO>(f=>
    {
       f.ForProperty(p=>p.ALongProperty).UseAlias("A");
       f.ForProperty(p=>p.AnotherLongProperty).UseAlias("B");
       //etc.
    }
   }
   public string ALongProperty {get;set;}
   public int AnotherLongProperty{get;set;}

}

;-)

//Andrew Theken

In my class I have

public class Item
{
    static Item()
    {
        MongoConfiguration.Initialize(
            cfg=> cfg.For<Item>(
                c => {
                    c.ForProperty(i => i.Name).UseAlias("N");
                    c.ForProperty(i => i.Description).UseAlias("D");
            })
        );
    }
    public String Name { get; set; }
    public String Description { get; set; }
}

After I save them there are items in DB with short key namse, the problem is when I try to read up all previously created items on start I get no items back.

© Stack Overflow or respective owner

Related posts about c#

Related posts about mongodb