should i bind intermediate enitities to my page or primary ones?

Posts   
 
    
nilsey
User
Posts: 54
Joined: 11-Jan-2008
# Posted on: 10-Jun-2008 00:55:34   

this is kind of a philosophical question.

Lets suppose i have an entity SurveyEntity and an entity QuestionEntity. In teh dtaabse, Questions may be assigned to Surveys via the intermediate table SurveyQuestion which maps to an "intermediate" entity SurveyQuestionEntity.

Now then, when I want to assign questions to a survey, should I instantiate a QuestionCollection (say in a data list or gridview of some kind on the page) and finally assign them to my Survey by iterating and creating SurveyQuestionCollection? This is like picking from a list of questions and assigning them to the survey.

Or should i create the SurveyQuestionCollection, bind the collection to the page (a little trickier because I have to display the properties of the SurveyQuestion's QuestionEntity), and then finally save that collection?

This has implications also for editing an existing collection of SurveyQuestion entities (if I have a survey that has already been set up wuth questions, i.e. has a SurveyQuestion collection, and now ia want to add or deleted assignments).

Is this making sense?

Walaa avatar
Walaa
Support Team
Posts: 14994
Joined: 21-Aug-2005
# Posted on: 10-Jun-2008 08:17:38   

Now then, when I want to assign questions to a survey, should I instantiate a QuestionCollection (say in a data list or gridview of some kind on the page) and finally assign them to my Survey by iterating and creating SurveyQuestionCollection? This is like picking from a list of questions and assigning them to the survey

That's how I normally do it.

When editing: Load the list of all available questions to pick from, with those associated with the survey already checked.

When the user finishes his modifications and hit save, I'd delete all entries in the intermediate table related to this specific survey, and then I save the new collection again.