I have two objects that have a ManyToMany relationship with one another through a mapping table. Though, when I try to save it, I get a stack overflow exception. The following is the code for the mappings:
//EventMapping.cs
HasManyToMany(x => x.Performers).Table("EventPerformer").Inverse().Cascade.AllDeleteOrphan().LazyLoad().ParentKeyColumn("EventId").ChildKeyColumn("PerformerId");
//PerformerMapping.cs
HasManyToMany<Event>(x => x.Events).Table("EventPerformer").Inverse().Cascade.AllDeleteOrphan().LazyLoad().ParentKeyColumn("PerformerId").ChildKeyColumn("EventId");
When I change the performermapping.cs to Cascade.None() I get rid of the exception but then my Event Object doesn't have the performer I associate with it.
//In a unit test, paraphrased
event.Performers.Add(performer); //Event
eventRepository.Save<Event>(event);
eventResult = eventRepository.GetById<Event>(event.id); //Event
eventResult.Performers[0]; //is null, should have performer in it
How should I be writing this properly? Thanks