Adding to m:n collection

Posts   
 
    
larkydoo
User
Posts: 45
Joined: 30-Jun-2008
# Posted on: 30-Jun-2008 22:51:00   

I'm trying to add a record to an entity that has an m:n relationship wtih another entity. The code looks something like this:

<Edited by Daelmo to be readable simple_smile >

DropDownList ddlParticipantNumbers = (DropDownList)ParticipantNumbersDropDownList1.FindControl("ddlAverageNumberOfParticipants");
ParticipantNumberLookUpEntity myParticipantNumberEntity = new ParticipantNumberLookUpEntity(Convert.ToInt32(ddlParticipantNumbers.SelectedValue));     thisEvent.ParticipantNumberLookUpCollectionViaEventParticipantNumber.Add(myParticipantNumberEntity);
thisEvent.ParticipantNumberLookUpCollectionViaEventParticipantNumber.SaveMulti();

</Edited>

When I go to debug, the myParticipantNumberEntity object contains the entity I want it to contain. However, when the code all runs, the record is not saved to the database. Anyone have any ideas?

Thanks.

Laurie

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 01-Jul-2008 05:50:19   

Hi Laurie, in LLBLGen Pro, m:n relations are read-only, therefore, to do something like that I recommend you to read this (search the "How do I add an entity A to an entity B's collection of A's if A and B have an m:n relation ?" example).

David Elizondo | LLBLGen Support Team