cancel
Showing results for 
Search instead for 
Did you mean: 

Comparing Collections with different number of columns

AS
Level 4

Hi, 

I have two collections, coll A and Coll B, CollB has all the columns of coll A and an additional column "Result", Now the problem is I have to compare the collections and find out the unique values from them and write thrm in another collection. 



------------------------------
A S
------------------------------
1 BEST ANSWER

Helpful Answers

HI As,
 I assume you dont want the other additional  column present in the collection B?
Multiple ways you can get the values
1) Merge both the collection ( If you have the same columns) and get unique values 
2) Loop the collection A and check the collectionB  contain value if it is  True then add the row in the new collection
3.) Check this thread for Inner Join:
https://community.blueprism.com/viewdocument/re-comparing-collections?CommunityKey=3743dbaa-6766-4a4d-b7ed-9a98b6b1dd01&tab=librarydocuments?utm_source=blueprism&utm_medium=pweb&utm_campaign=gl-web-20...
4) Write Code stage ( C# or vb.net):
VB.Net:
INput parameters: I_Collection_BI_Collection_B
Output  parameters: O_Collection

O_Collection = I_Collection_A.AsEnumerable().Intersect(I_Collection_B.AsEnumerable(),DataRowComparer.Default).CopyToDataTable()

In the initailize action  under code option make sure the external references and Name spaces are present:
External reference:
System.Core.dll
System.Data.DataSetExtensions.dll 
NameSpaces:
System.Data.DataSetExtensions


Check some other useful articles 
https://learn.microsoft.com/en-us/dotnet/framework/data/adonet/comparing-datarows-linq-to-dataset
https://social.msdn.microsoft.com/Forums/en-US/cb8ef7f7-5e7f-4448-9181-4111942b1a7c/how-to-compare-two-data-tables-and-create-a-new-data-table-based-on-the-compared-results-c?forum=aspwebformsdata
https://stackoverflow.com/questions/11862113/how-to-compare-2-datatable-and-get-unique-records-in-3rd-datatable
System.LINQ



------------------------------
-----------------------
If I answered your query. Please mark it as the "Best Answer"

Harish M
Lead developer
America/New_York TX
------------------------------

-----------------------
If I answered your query. Please mark it as the Best Answer

Harish Mogulluri

View answer in original post

1 REPLY 1

HI As,
 I assume you dont want the other additional  column present in the collection B?
Multiple ways you can get the values
1) Merge both the collection ( If you have the same columns) and get unique values 
2) Loop the collection A and check the collectionB  contain value if it is  True then add the row in the new collection
3.) Check this thread for Inner Join:
https://community.blueprism.com/viewdocument/re-comparing-collections?CommunityKey=3743dbaa-6766-4a4d-b7ed-9a98b6b1dd01&tab=librarydocuments?utm_source=blueprism&utm_medium=pweb&utm_campaign=gl-web-20...
4) Write Code stage ( C# or vb.net):
VB.Net:
INput parameters: I_Collection_BI_Collection_B
Output  parameters: O_Collection

O_Collection = I_Collection_A.AsEnumerable().Intersect(I_Collection_B.AsEnumerable(),DataRowComparer.Default).CopyToDataTable()

In the initailize action  under code option make sure the external references and Name spaces are present:
External reference:
System.Core.dll
System.Data.DataSetExtensions.dll 
NameSpaces:
System.Data.DataSetExtensions


Check some other useful articles 
https://learn.microsoft.com/en-us/dotnet/framework/data/adonet/comparing-datarows-linq-to-dataset
https://social.msdn.microsoft.com/Forums/en-US/cb8ef7f7-5e7f-4448-9181-4111942b1a7c/how-to-compare-two-data-tables-and-create-a-new-data-table-based-on-the-compared-results-c?forum=aspwebformsdata
https://stackoverflow.com/questions/11862113/how-to-compare-2-datatable-and-get-unique-records-in-3rd-datatable
System.LINQ



------------------------------
-----------------------
If I answered your query. Please mark it as the "Best Answer"

Harish M
Lead developer
America/New_York TX
------------------------------

-----------------------
If I answered your query. Please mark it as the Best Answer

Harish Mogulluri