I have three entity framework objects, Quiz, Question, and Option. A Quiz has a collection of Question objects, and a Question has a collection of Option objects. I would like to return from the DBContext
a randomized list of questions for a specified quiz and each question should include a randomly sorted collection of associated Options.
So far, I have been able to get the random list of questions out successfully, but I am having trouble randomizing the options for the question.
Note: I have a couple of different shuffling extension methods I have written, in this example I am using ordering by a Guid for sake of simplicity.
var questions = db.Questions.Where(q => q.QuizId == quizId).Include(q => q.Options).OrderBy(a => Guid.NewGuid());
How can I randomly shuffle the Options?