I want to select 20 Random records from a SQLite table of 100 records.
Here is my code and I'm getting the following error. $exception {"Order By does not support: x => NewGuid()"} System.NotSupportedException
int tempRun = 10;
var dbPath = Path.Combine("OPS.db");
using (var db = new SQLite.SQLiteConnection(dbPath))
{
var rec = db.Table<CoversData>().Where(p => p.homeR >= tempRun).Take(15);
var randomrec = db.Table<CoversData>().OrderBy(x => Guid.NewGuid()).Take(15);
// error {"Order By does not support: x => NewGuid()"} System.NotSupportedException
foreach (CoversData cd in rec)
{
ResultsListBox.Items.Add(cd.Id.ToString() + " " + cd.GameDate + " " + cd.HometeamName + " " + cd.homeR.ToString());
}
}
The answer should be using the Linq format not SQL Select statement.