But as per my understanding it should be f(“Id”) and then d(“QueueDefinitionId”), because f belongs to QueueDefinitionsDT and d belongs to QueueItemsDT. Can you please correct me if my understanding is wrong?
I assume your linq query is taking each Id from QueueDefinitionsDT and trying to match to QueueDefinitionId for every row in QueueItemsDT and then preparing Name column in FinalQueueDT. Am I correct? If not, can you please elaborate what this linq query does?
You are correct. It was just swapped. Can you test again?
Let qn = QueueDefinitionsDT.Where(Function (f) f("Id").toString.Trim.Equals("d("QueueDefinitionId").toString.Trim)).Select(Function (x) x("Name").toString).DefaultIfEmpty("Undefined").First()
Here we are searching in QueueDefinitionsDT for the Id from our QueueItemsDT row
In case of we do not find then we are returning a default value “Undefined” in our imp
Why would you copy the value from one table to another? This is two tables in a relational format, and you can use a SQL join to get the resulting data you want without actually copying the value. This is valuable, because if something changes in one table, you don’t have to worry about updating the other table - it’s relational. The point to relational data is you don’t have to copy values from one table to another.
SELECT * FROM QueueDefinitionsDT.*, QueueItemsDT.* FROM QueueItemsDT INNER JOIN QueueDefinitionsDT ON QueueDefinitionsDT.Id = QueueItemsDT.QueueDefinitionId
yes. I’m learning from tutorialsteacher.com as you said in your previous replies to my another posts.
Sorry to bother you once again. Data is not in DB. It’s directly in data table variables. I tried .AsEnumerable for both data tables and I got the following error:
Multiple Assign - Final Queue DT: Can not assign ‘(From d In QueueItemsDT.AsEnumerable
Let qn = QueueDefinitionsDT.AsEnumerable.Where(Function (f) f(“Id”).tostring.trim.equals(d(“QueueDefinitionId”).tostring.trim)).Select(Function (x) x(“Name”).tostring).DefaultIfEmpty(“Undefined”).First()
Let ra = d.ItemArray.Append(qn)
Select r= FinalQueueDT.Rows.Add(ra)).CopyToDataTable’ to ‘FinalQueueDT’.
I’m not able to understand what went wrong. Can you please help?
May we ask you to compare to your implementation thanks
OK, so things cannot be done in SQL directly
As an alternate find a inner join approach here:
(From d1 In QueueItemsDT.AsEnumerable
Join d2 In QueueDefinitionsDT.AsEnumerable
On d1("QueueDefinitionId").toString.Trim Equals d2("Id").toString.Trim
Let qn =d2("Name").tostring
Let ra = d1.ItemArray.Append(qn)
Select r= FinalQueueDT.Rows.Add(ra)).CopyToDataTable
Ensutre that from Copy & Paste all " are correctly taken and no “ or ” is used
Doesn’t matter. Inner Join will only give you matching rows. Outer Join will give you all rows from one table, plus matching rows from the other table.
“QueueItemsDT contains many rows of data where QueueDefinitionId can be a duplicate.”
This linq which prepares FinalQueueDT is valid syntactically. I cross checked and it looks correct. Also updated case properly in toString, Trim and Equals. Still I’m getting same error.
Here it is:
Multiple Assign - Final Queue DT: Can not assign ‘(From d In QueueItemsDT.AsEnumerable
Let qn = QueueDefinitionsDT.AsEnumerable.Where(Function (f) f(“Id”).toString.Trim.Equals(d(“QueueDefinitionId”).toString.Trim)).Select(Function (x) x(“Name”).toString).DefaultIfEmpty(“Undefined”).First()
Let ra = d.ItemArray.Append(qn)
Select r= FinalQueueDT.Rows.Add(ra)).CopyToDataTable’ to ‘FinalQueueDT’.
This time I used “FinalQueueDT” in both left hand side and right hand side of assign activity
use single assign
use statement as tested and provided (Post 14)
About ValidationMessage - if it is failing then create screenshot from hover containing the message
Test alternate Join Syntax