I read a few answers to a similar query, but no one seems to hit the mark.
Imagine I have a table containing 10 rows, how can I get 3 random rows from this table using Entity Framework? Not only 1 random line, but 3 random lines - each of them is different from the other?
Thanks in advance
var threeRandomFoos = foos.OrderBy(x => Guid.NewGuid()).Take(3);
Instead, there is an easier way:
var threeRandomFoos = foos.OrderBy( x=> SqlFunctions.Rand()).Take(3);
Guid.NewGuid will be a little slower in performance, why not use the Random defined by SqlFunctions itself?