I have a Table of Companies, and I'm trying to build a matrix of competitors between them.
For example: McDonalds is a Competitor of Wendy's, and vice-versa.
Here's the mappings I've tried:
HasManyToMany(x => x.Competitors)
.ParentKeyColumn("IssuerID")
.ChildKeyColumn("CompetitorID")
.Table("Competitors")
.Cascade.All().Not.LazyLoad();
as well as:
Table("Issuer");
Id(x => x.Key).Column("Id").GeneratedBy.Assigned();
Map(x => x.Name).Length(1000);
HasManyToMany(x => x.Competitors).ParentKeyColumn("IssuerID").ChildKeyColumn("CompetitorID").Table("Competitors").Cascade.All().Not.LazyLoad();
When I add a competitor to an Issuer, I can see the correct mapping in the database.
So If I do:
McDonalds.AddCompetitor(Wendys);
I will see the correct data in the DB. I will also see the correct DB in the Entities when i get McDonalds using NHibernate.
But, if I return Wendy's from Nhibernate and look at the Competitors object:
Wendys.Competitors
I don't see McDonalds. I can understand why because Wendy's was added to McDonalds as a Child.
How can I modify this so I can view the competitors from both directions?