<p>I would like to return all rows from <code>TableA</code> table that does not exists in another table.</p>

<p>e.g.   </p>

<pre><code>select bench_id from TableA where bench_id not in (select bench_id from TableB )
</code></pre>

<p>can you please help me write equivalent LINQ query. Here <code>TableA</code> is from Excel and <code>TableB</code> is from a Database </p>

<p>I am loading Excel sheet data into <code>DataTable</code>, <code>TableA</code>. <code>TableB</code> I am loading from Database. In short, <code>TableA</code> and <code>TableB</code> is type of <code>DataTable</code></p>

So if table A is from Excel, are you loading the data into memory first? If so (i.e. you're using LINQ to Objects) then I suggest you load the IDs in table B into a set and then use:
```
```
var query = tableA.Where(entry => !tableBIdSet.Contains(entry.Id));
```
```
If this isn't appropriate, please give more details.
Converting into a set is probably best done just by using
the HashSet constructor which takes an
```
IEnumerable<T>
```
. For example:
```
```
var tableBIdSet = new HashSet<string>(db.TableB.Select(entry => entry.Id));
```
```
(If the IDs aren't actually distinct, you could add a call to Distinct() at the end.)