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
Post a Comment