Search
Learn
Share

Select random rows in Entity Framework

Published by Profile Image DevDashboard on 3 March, 2016
395 views
You can order by a new guid to create a random order:

Randomly order:
something.OrderBy(r => Guid.NewGuid());

Example

Select 5 random rows:
something.OrderBy(r => Guid.NewGuid()).Take(5);