Random row from Linq to Sql

前端 未结 15 2318
南笙
南笙 2020-11-22 05:39

What is the best (and fastest) way to retrieve a random row using Linq to SQL when I have a condition, e.g. some field must be true?

15条回答
  •  广开言路
    2020-11-22 06:04

    I have random function query against DataTables:

    var result = (from result in dt.AsEnumerable()
                  order by Guid.NewGuid()
                  select result).Take(3); 
    

提交回复
热议问题