How to perform linq to connect activity

@supermanPunch if string is sofa it will return id as 1(from items table)
else 0

@pranay.a In that case, you would just need the items table, and no need of the other table

@supermanPunch both tables have foreign key references if dynamic string matches with itemName need to return itemId so can place it in OrderRequest table which will accept int(itemid)

@pranay.a Can you check if you are able to execute the Below Activity in the Screenshot?

Can you use the activity according to the above pic, and check if you’re able to execute it prperly? Use the Output of Connect Activity as the Existing Connection value. Declare a Datatable DT and provide it as the Output variable for the activity.

If it works then we can just use a linq on the DT variable to get the ItemId. We’ll later check if that’s what you actually needed.

1 Like

@supermanPunch will try now

@supermanPunch it is working

1 Like

@pranay.a Ok. Now let’s say your dynamic String is in a String variable named itemName .

You can use the below Linq Query in an Assign Activity to get the matching ID value.

Id = DT.AsEnumerable.Where(Function(x)x(“ItemName”).ToString.ToLower.Trim.Equals(itemName)).Select(Function(x)x(“ItemId”).ToString).First

Id goes on the Left Side of Assign
Query goes on the Right Side

Where Id is a String variable.

@supermanPunch Thank you man for your efforts.

1 Like

@pranay.a Please Confirm by testing for different data’s if that is the result you need.

1 Like

@pranay.a Sorry, there might be small blunder in it. Use the below Query instead


am getting issue related to AsEnumerable is not a member of data table ?

@pranay.a Yes. For that you would need to make changes in the xaml file as I have Suggested in this post. But be careful in doing so, maybe keep a backup of the xaml before doing it.

1 Like

@supermanPunch Assign: Object reference not set to an instance of an object. getting this issue

@pranay.a Is the dynamic string provided present in the items table ?


@pranay.a Ok. I would have to modify the way we have executed the Linq query by adding extra conditions.

1 Like

@pranay.a The post below has a fix for the similar error that you are getting in here. Can you maybe try to modify it accordingly but according to the Linq query I have provided. If you get confused I’ll prepare Screenshots and explain the same steps.

will work on it and let u know tomorrow

1 Like

it is completely different when compared with my scenario how it will work ?

@pranay.a Did you understand the Try Catch method ?