I have a database with x amount users and I want to randomly get all the users and then write like 50 users out on my site. Right now I\'m only using .take(50)
.take(50)
Extension Without Random
public static class MyExtensions { public static IEnumerable GetRandomItems(this IEnumerable source, Int32 count) { return source.OrderBy(s => Guid.NewGuid()).Take(count); } }
And now you can
userList = userList.GetRandomItems().ToList();