orm - Mapping join in fluent nhibernate -


i working legacy database represents hierarchy. objects represented follows (simplified version):

class key  {      public virtual int id { get; set; }      // more properties }  class leaf {      public virtual int id { get; set; }      public virtual key key { get; set; }      public virtual key parent { get; set; } }  class branch {     public virtual int id     { get; set; }     public virtual key key    { get; set; }     public virtual key parent { get; set; } } 

the mapping above obvious "key" being mapped foreign key key table.

there no direct relationship between leaf , branch. effectively, through key, leaf has many-to-one relationship branch. hence leaf can have 1 parent, , branch can have 1 parent.

i provide join map, can provide parentbranch property class leaf, such can access branch.

leaf leaf; branch branch = leaf.parentbranch; 

the query can written

            var parent = session.queryover<branch>()                 .where(br => br.key == leaf.parentkey)                 .singleordefault(); 

is there way map query leaf.parent in nhibernate/fluent nhibernate? being legacy database, not possible simplify schema now.

persistence of these objects poses challenge. think, separate question.


Comments

Popular posts from this blog

Unable to open serial port using Putty to bluetooth device on windows 7 64 bit -

bash - How do you programmatically add a bats test? -

java - Getting exception in JDBC thin driver -