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()
Thank you for quick response,
I have tried above query and returning only two rows. Suppose having 50 rows are in datatable and i need to get around 5 entire datarows. how can i achieve it?
You can find the solution attached.
I am also adding the C# code block below, you can paste it after you create the invoke activity with the C# property:
out_DataTable = in_DataTable.Clone();
Random random = new Random();
HashSet selectedIndices = new HashSet();
int numberOfRandomRows = random.Next(1, in_DataTable.Rows.Count-1);
var randomIndices = Enumerable.Range(1, in_DataTable.Rows.Count-1).OrderBy(x => random.Next()).Take(numberOfRandomRows);