I need to get out of how I find a random thing in the database as shown to the audience and at the same time it must be able to show one of time.
Normally I have done like this
cmd1.CommandText = @"SELECT TOP 1 opgaver.id, opgaver.rigtigsvar, opgaver.overskift, opgaver.svar1,
opgaver.svar2, opgaver.svar3, opgaveLydefiler.mp3 FROM opgaver INNER JOIN opgaveLydefiler ON opgaver.overskift = opgaveLydefiler.navn ORDER BY newid()";
Tasks and task sounds files are put together such that they, like partnerships / has an inner join together.
I've tried to do like this, but I can not right for it to display only one and the same time make a random of it as I have in the database.
Opgaver opgaver = db.opgavers.FirstOrDefault().Take(1);
EIDT - I have chosen to do like this,
var random = new Random();
var antalopgaver = db.opgavers.Count();
var number = random.Next(antalopgaver);
var randomlySelectedItem = db.opgavers.Skip(number).Take(1).FirstOrDefault();