I have Questions table and List of CategoryIds. I have to get one question from each CategoryId randomly. Right now I'm doing like this:
var randomQuestions = new List<Question>();
foreach(int id in categoryIds){
randomQuestions.add(questions.Where(o => o.CategoryId== id).OrderBy(o => Guid.NewGuid()).FirstOrDefault());
}
But is there way to do it only with Linq? Thanks