I have the following data types
table1
+-----------+------+------+ | catalogid | name | snum | +-----------+------+------+ | 353 | xx | 4 | | 364 | yy | 3 | | 882 | zz | 3 | | 224 | mm | 71 | | 999 | kk | 321 | | 74 | kk | 4 | | 54 | ii | 5 | | 11 | u | 6 | | 23 | yy | 6 | +-----------+------+------+
table2
+-----------+----------+--------------+ | catalogid | numitems | ignoreditems | +-----------+----------+--------------+ | 353 | 4 | 0 | | 364 | 10 | 0 | | 882 | 2 | 0 | | 224 | 0 | 7 | +-----------+----------+--------------+
Using LINQ, I want to join them and copy the result into a new datatable. They both share catalogid , and as a result, it should only display entries that their cataloging exists in table2
result
+-----------+------+------+-----------+---------------+ | catalogid | name | snum | numitems | ignoreditems | +-----------+------+------+-----------+---------------+ | 353 | xx | 4 | 4 | 0 | | 364 | yy | 3 | 10 | 0 | | 882 | zz | 3 | 2 | 0 | | 224 | mm | 71 | 0 | 7 | +-----------+------+------+-----------+---------------+
Here is my attempt, but it does not work:
Dim query = From a In oresult.AsEnumerable Group Join b In products.AsEnumerable On a.Field(Of Integer)("catalogid") Equals b.Field(Of Integer)("catalogid") Into Group query.copytodatatable
CopyToDatatable does not work and I cannot understand why
source share