Looking for a one-liner vs doing a loop

I’m looking for a one-liner of code in an Assign activity vs using a loop structure.

Simple schema of my data table. This is not all columns but the related ones to this question.

  • Reference
  • OrderID

(And yes, this data table is destined for a queue set to Unique in Orchestrator).

My OrderID column will have values of like so: 11111111

What I need is the following done to the OrderID value for each row copied to the Reference field for that row with the following format:

<OrderID>=<GUID value>

I have a loop and an assign activity that basically does this:

row.Item(“Reference”) = row.Item(“OrderID”).ToString+"="+Guid.NewGuid().ToString

(And, yes, I know the Reference column of an Orchestrator queue should already be unique :slight_smile: … just bare with me)

This works fine but for a large number of rows it adds up. As such, I’m looking to see if there is a one liner that could do the same thing but MUCH faster. By a one-liner I mean something similar in concept to this:

dt_OrderLinesFiltered = dt_OrderLinesFiltered.AsEnumerable.Where(Function(r) If(IsDate(r(“Start Date”).ToString.Trim),Convert.ToDateTime( r(“Start Date”).ToString.Trim ) > date_dateToleranceBack,False) ).CopyToDataTable

I found a reference to the AsEnumerable example on some web forum and hacked (hacked as in my programming ability) into UiPath and it works VERY quickly to filter out all rows whose “Start Date” value is greater than a computed earlier date value.

Hoping someone can let me know if there is a one-liner to do the loop-over-all-and-copy-a-with-value-formatting example that is faster than using a loop-with-assign approach.

Not the complete code. However, you can start with this.

IEnumerable<string> uniqueIds = table.AsEnumerable().Select (r => string.Format ("{0}={1}", r.Field<string> ("OrderID"), Guid.NewGuid().ToString));

Dim uniqueIds As IEnumerable(Of String) = table.AsEnumerable().[Select](Function(r) String.Format("{0}={1}", r.Field(Of String)("OrderID"), Guid.NewGuid().ToString))

Thanks !!! I’ll give it try once I knock out another workflow I’m working on.