Hello, I have a Question table which joins to a Solution table. The solutions are linked to the questions but in order to delete a question, i must delete the solutions for that question first and then delete the question itself.
I have a linq query that retrieves all solutions for a specified question however i am unsure how to proceed with the deletion of the solutions and then consequently proceed to delete the question. Help appreciated greatly.
Here is the code, it recieves overload error messages:
public static void DeleteSol(string qTextInput)
{
ExamineDataContext dc = new ExamineDataContext();
var matchedSol = from q in dc.Questions
where q.QuestionText.Contains(qTextInput)
join s in dc.Solutions
on q.QuestionID equals s.QuestionID
into qs // note grouping
select new
{
solution = qs
};
try
{
dc.Solutions.DeleteOnSubmit(matchedSol);
dc.SubmitChanges();
}
catch (Exception ex)
{
throw ex;
}
}