开发者

complicated relation fluent nhibernate

开发者 https://www.devze.com 2023-03-21 20:45 出处:网络
hey all i\'m not sure how to map this. i have got buyer, buyer can have many buyers. then i got contract,

hey all

i'm not sure how to map this.


i have got buyer,

buyer can have many buyers.

then i got contract,

now, for each contract the buyer have many different buyers..

  public class Buyer
{
    private IList<Buyer> m_buyerList = new List<Buyer>();
    pub开发者_Go百科lic virtual IList<Buyer> BuyersList
    {
        get { return m_buyerList; }
        set { m_buyerList = value; }
    }

    public virtual string Name { get; set; }
    public virtual int ID { get; set; }
    public virtual string Address { get; set; }
    public virtual string ExtraAddress { get; set; }
    public virtual string PhoneA { get; set; }
    public virtual string PhoneB { get; set; }
    public virtual string PhoneC { get; set; }
    public virtual string Email { get; set; }
    public virtual string Fax { get; set; }
}


public class Contract
    {
        public virtual Buyer MainBuyer { get; set; }
        public virtual DateTime SignedDate { get; set; }
    }

thank you guys.


Buyer mapping:

  HasManyToMany(x => x.BuyersList)     
  .ParentKeyColumn("ParentBuyerId")     
  .ChildKeyColumn("BuyerId")  

Contract mapping:

References(x => x.MainBuyer);
0

精彩评论

暂无评论...
验证码 换一张
取 消