In MSSQL, we can use NewID function to retrieve a random row. select top 1 * from table order by NewID() How can we implement it with LINQ? There is a Skip function can do the same thing. resultList.Skip(new Random().Next(resultList.Count)).First(); Below is the sample. RandomInLINQ.aspx using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI;... Read more »
↧