I have the following piece of code:
private Random r = new Random();
private List<T> RandomElement<T>(IQueryable<T> list, Expression<Func<T, bool>> e, int items = 3)
{
list = list.Where(e);
return list.Skip(r.Next(list.Count())).Take(items).ToList();
}
The problem is when I call it and want for example to return 3 random items from a list, sometimes returns 3 sometimes 2, sometimes 1 ?
I want at all time to get 3.
What I am doing wrong?