Get a random row with LINQtoSQL

后端 未结 6 1567
忘掉有多难
忘掉有多难 2021-01-20 04:39

Is there a way to return a random row from a table using LINQToSQL?

6条回答
  •  梦毁少年i
    2021-01-20 05:39

    technically:

    var randomRow = (from rows in db.Table
      select shipper).First();
    

    because you can't ever be sure of the row order, unless you specify the order by clause.

提交回复
热议问题