Scenario:-
You have a list of dictionaries where each dictionary represents a product with a “Name” and “Price” field. How would you find the product with the highest price using LINQ in UiPath?
Use this LINQ
maxPriceProduct = products.OrderByDescending(Function(product) Convert.ToDouble(product("Price"))).First()
Thanks,
Ashok
highestPriceProduct = products.OrderByDescending(Function(p) Convert.ToDecimal(p("Price"))).First()
highestPriceProduct = products.OrderByDescending(Function(p) Convert.ToDecimal(p(“Price”))).First()
Cheers
1 Like
Let’s say ProductPrice is the Dictonary of String, Object datatype variable.
HighestPricedProduct is the String variable which stores the Product which has high cost
Use the below linq expression in assign activity,
- Assign -> HighestPricedProduct = ProductPrice.OrderByDescending(Function(p) Convert.ToDouble(p("Price"))).First()("Name").ToString()
The above expression will get the Highest price product in the Dictionary variable.
Hope it helps!!
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.