4
I have two tables that come from different repositories. One comes from an API and I have one that comes from BD.
I already have the two tables mapped to classes.
I want to select all records from table A that are not in table B.
Using a foreach would be something like :
var result = new List<A>();
foreach (var item in A)
{
if (!B.Any(x => x.codigo == item.codigo))
{
result.Add(item );
}
}
I tried to use LINQ, but I was unsuccessful.
Follows the code used:
var result = from a in ListA
join b in ListB
on a.Codigo equals b.Codigo
into tmpMapp
from m in tmpMapp.DefaultIfEmpty()
select a;
In SQL would be
SELECT a LEFT JOIN b on a.Codigo = b.Codigo