The following section of code works as I want it to

```
for (int i = 1; i <= practicehistory.TotalNumQuestions; i++)
{
    query = from a in db.Questions
            where a.CategoryId == practicehistory.CategoryId
            orderby a.QuestionId
            select a;
    randomNumber = random.Next(1, count + 1);
    int qNum = query.Skip(randomNumber - 1).First().QuestionId;
    asked.QuestionId = qNum;
    asked.OrderAsked = i;
    db.AskedHistories.Add(asked);
    db.SaveChanges();
}

```

However, I am occasionally getting situations where the random number is the same as a random number on a previous for loop run. I wonder then if anyone has an elegant solution to how I can make sure to only generate a random number than has not been previously generated before? I am thinking of populating an array and checking against this but this seems rather redundant!