How to map it? HasOne x References

Posted by Felipe on Stack Overflow See other posts from Stack Overflow or by Felipe
Published on 2010-05-06T18:52:37Z Indexed on 2010/05/06 20:48 UTC
Read the original article Hit count: 162

Hi everyones,

I need to make a mapping One by One, and I have some doubts. I have this classes:

public class DocumentType {    
    public virtual int Id { get; set; }    
    /* othes properties for documenttype */  
    public virtual DocumentConfiguration Configuration { get; set; }
    public DocumentType () { } 
}

public class DocumentConfiguration {
   public virtual int Id { get; set; }
   /* some other properties for configuration */   
   public virtual DocumentType Type { get; set; }

  public DocumentConfiguration () { }
}

A DocumentType object has only one DocumentConfiguration, but it is not a inherits, it's only one by one and unique, to separate properties.

How should be my mappings in this case ? Should I use References or HasOne ? Someone could give an example ?

When I load a DocumentType object I'd like to auto load the property Configuration (in documentType).

Thanks a lot guys!

Cheers

© Stack Overflow or respective owner

Related posts about fluent-nhibernate

Related posts about nhibernate-mapping