0

So I've 2 DataTables like this:

table1:    |mean1|mean2|   table2: |mean1|mean2|
           -------------           -------------
           |1.2  | 1.3 |           |2.2  | 1.3 |
           |2.0  | 2.0 | <=======> |2.0  | 2.0 |
           |1.0  | 2.3 |           |3.0  | 1.0 | 
           |1.4  | 2.7 |           |3.0  | 1.2 |
           |1.5  | 2.8 |           |2.7  | 1.3 |
           |2.2  | 1.1 | <=======> |2.2  | 1.1 |

My goal is to find values from table2 which are included in table1. It must be written in VB.Net

Code for finding duplicates in table1 only looks like:

Dim dupes = From row In table1.AsEnumerable()
            Group row By G = New With {.mean1= row.Field(Of Double)("mean1")}.mean1,
            New With {.mean2= row.Field(Of Double)("mean2")}.mean2 Into DupMean = Group
            Where DupMean.Count() > 1
            Select DupMean

How can I combine the code with the table2 ?

1 Answer 1

1

Something like that

Dim dupes = From row In table1.AsEnumerable()
            Join row2 In table2.AsEnumerable()
            On row("mean1") Equals row2("mean1") And row("mean2") Equals row2("mean2")
            Select New With {.RowInT1 = row, .RowEqualInT2 = row2}

Or, for include an internal duplicate of each table:

Dim dupes = From row In table1.AsEnumerable().Concat(table1.AsEnumerable()()
            Group row By G = New With {.mean1 = row("mean1"), .mean2 = row("mean2")}
            Into DupMean = Group
            Where DupMean.Count() > 1
            Select DupMean
Sign up to request clarification or add additional context in comments.

1 Comment

the Field(Of T) Method Unnecessary here, in my opinion.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.