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

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -