What should be the return type for the anonymous type lamda query

Hello all,

I am creating an anonymous object using lamda expression and assigning to the IEnumerable type variable.

Below lamda exp x is the datarow type from the datacolumn and Key.Value is the value from country column and index is one of the input parameter to the select method.Assigning to Ienumerable
dt1.AsEnumerable.Select(Function(x,y) New With {Key.Index =y, Key.Value = x(“Countries”).ToString})

When i loop through the collection i don’t see the properties(Index and Value) defined in the anonymous type but i am able to get the all the values like below

As per the below screenshot i don’t see the Index and Value properties in the object valriable.Appreciate your help on this

Hi @raja.raviraj

Hope i didn’t misunderstood your query
If you use the enumerable in the for each it will automatically get the next next data with iteration you don’t need a index.

If you need to pass it with index

you should use like enumAnany(0) something like this

If i misunterstood your query kindly explain me a bit more

Or if you are asking like you need to have it like a dictionary

Change the property of the for each to Dictionary



Hi @raja.raviraj ,

If I understood your query correctly, you are saying that intellisense isn’t bringing up the properties/attributes you have created for the object in the For Each Activity i.e.


If that is the case, then you have to understand that this is a limitation from UiPath.
The for each isn’t intelligent enough to understand this, but if you wish to actualize this then you must use this code within an Invoke Code Activity and create the anonymous object there.


Do give it a try.

Kind Regards,
Ashwin A.K


Can you try CallByName method as the following?

CallByName(currentItem, "Index", CallType.Get).ToString

However, it might not be very good because of cost of cast.

How about using Tuple?

iet = dt.AsEnumerable.Select(Function(x,y) Tuple.Create(y, x("Column1").ToString))

Sample20230103-1.zip (5.3 KB)


Thanks for all the suggestions

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.