SQL(通用于 SQL Server)
SELECT FROM Table ORDER BY NewID()
LINQ
t in Table orderby Guid.NewGuid()t
Lambda
Table.OrderBy(x=>Guid.NewGuid())
下面是随机取去前n条数据
SQL(通用于 SQL Server)
SELECT TOP n FROM Table ORDER BY NewID()
LINQ
(fom t in Table orderby Guid.NewGuid()t).Take(n)
Lambda
Table.OrderBy(x=>Guid.NewGuid()).Take(n)