Get Random Records using LINQ in .Net

on Oct 26, 2019 02:55 AM


i have this linQ query, how to get 6 random records on each page load

in sql we use to do order by new guid()

var q = (from p in db.Profiles
         where p.ProfileStatus == "Completed" && p.UserName != this.Page.User.Identity.Name
         select p).Distinct().Take(6).ToList();



Download FREE API for Word, Excel and PDF in ASP.Net: Download
on Oct 26, 2019 02:55 AM
Hi @nauna,
Please try the following

Get Random Records from Generic List (List) using LINQ in C# .Net

It might help you.

Cheers Andrea.