How to get random entire row in Linq from datatable

Hi @neelimaintern


Code:

Dim rand As New Random()

Dim randomIndices = Enumerable.Range(0, Dt.Rows.Count).OrderBy(Function(i) rand.Next()).Take(Dt.Rows.Count)

resultTable = (
    From index In randomIndices.Take(3)
    Select Dt.Rows(index)
).CopyToDataTable()

Invoke Arguments:

Regards

1 Like