Sorry about the confusing subject line 🙂
I want to make a SQLlike query with my DataTable:s: I want to do something like this
// Is named "BadValues" Rows contain: id1, id2
DataTable tableReadFromFile = readFromFile();
// Is named "AllValues" Rows contain id1, id2
DataTable tableReadFromSql = readFromSql
DataTable resultTable =
tableReadFromFile.select("where AllValues.id1 not in (select id1 from BadValues) and AllValues.id2 not in (select id2 from BadValues)");
So if my “BadValues” table would look like this:
id1 id2
0 1
10 11
20 21
and my “AllValues” table would look like this:
id1 id2
0 1
0 2
1 1
10 11
10 12
12 11
20 21
20 22
22 21
I would like the resultTable to look like this:
id1 id2
0 2
1 1
10 12
12 11
20 22
22 21
In other words: if the pair id1,id2 exists in the table “BadValues” and in “AllValues” I want to remove them so that they don’t exist in the result table.
This would have been rather simple to do in SQL if the table “BadValues” would exist in the SQL database, but since it is loaded from file that is not possible.
As it is now, I loop through all rows in the “BadValues” and construct individual SQL queries with the id1 and id2 values set. Since I have quite a lot of data, that is very time consuming.
Any tip is appreciated!
Using Linq to dataset:
The first statement basically creates a hashset of the tuples which represent the bad values.
The second searches in the second table the rows which ids are not in the hashset.