Search code examples
linquipath

How to write linq query with multiple conditions in UiPATH


Before asking the question, I don't speak English very well. We apologize for asking again because it is difficult to understand other similar questions.

Question : I want to use linq query with multiple conditions in UiPATH. Condition 1 : If there is "A" in row, change it to "Alpha". Condition 2 : If there is "B" in row, change it to "Beta". ... Condition n(it may be more than 10) : If there is "O" in row, change it to "Omega".

I used the "find and replace" activity, but the higher the number, the slower the processing. As a solution to this, I learned about linq query, but it is difficult to apply and use the basic example. please help.. thanks..


Solution

  • So there is a couple ways you could do this.

    Option 1 - If it's a DataTable that your using then utilise the 'For Each Row' activity. Then within the for each. Use the Assign activity

    enter image description here

    So this would change the value of that row. So you could add your if statement there.

    Option 2 - Use the Invoke Code Activity - set language to C# (or VB - whichever you prefer) In the Arguments, put your DataTable you are using. Then go to Edit Code and Input your Linq Statement there.