I have a Answer table which has pk_answerid, answertext , fk_questionid, chosenoptions stored as 1,3,2 (comma separated)
answertext if populated, then chosenoptions null and if chosenoptions if populated then answertext is null.
ChosenOption table has structure pk_chosenoptionid, fk_questionid In EntityFramework 4, I have something along these lines
void SaveAnswers(ICollection<Answer> answers)
{
context.Answers.Add(answers);
context.SaveChanges();
}
This works fine....but when in the UI I go back to page which is wizard with Q&A's on different pages and I deselect all answers previously selected, and click save, no answers are deleted. I also tried DeleteObject which does not delete the Answers and chosenoptions even though I have cascade delete on the Answer table to Chosen option table. Also in edit scenarios if for e.g. if the User selected option 1,2 and then saves it and then goes back and selects 3,2 how do you write code in EF to do such complex stuff. I haven't come across any tutorials which explain such scenarios. Most of what I have seen is simple add, delete and applypropertychanges. I have an MVC app, which has lazy loading enabled. Pls help and suggest some sort of code using an example or any pointers to existing blogs where this is explained.