c# - self referencing in the same table in fluent n hibernate -


i have map company own parentcompany column other companyid unique identifier unable write mapping configuration same.

      public class company      {      public virtual int companyid { get; set; }     public virtual string companyname { get; set; }     public virtual string addressline1 { get; set; }     public virtual string addressline2 { get; set; }     public virtual string state { get; set; }     public virtual state stateref { get; set; }     public virtual long? duns { get; set; }     public virtual long? dunsultimateparent { get; set; }     public virtual company ultimateparentcompany { get; set; }     } 

for particular company , duns number unique primary key companyid . , corresponding ultimateparentcompany should mapped through dunsultimateparent column duns column. hope clear.

i have come below mapping not working searching companyid , not in duns.

  references(x => x.ultimateparentcompany).column("dunsultimateparent") 

try :

public class company      {     public virtual int companyid { get; set; }     public virtual company parent{ get; set; }     public virtual ilist<company>children{get;set}     }  references(x => x.parent, "parentid").nullable();             hasmany(x => x.children).cascade.saveupdate().keycolumn("parentid"); 

this how self referencing should like.


Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -