Determining the Difference Between Two Entity Sets Using LINQ
Determining the Difference Between Two Entity Sets Using LINQ
Join the DZone community and get the full member experience.
Join For FreeWhat follows is a way to get the row(s) to form table_A which are not part of table_B
SELECT <select_list>
FROM Table_A A
LEFT JOIN Table_B B
ON A.Key = B.Key
WHERE B.Key IS NULL
</select_list>
In Linq to Sql you can achieve same thing just by calling one function exception.
var infoQuery =
(from tblA in db.Table_A
select tblA.Key)
.Except
(from tblB in db.Table_B
select tblB.Key);
So by using above query you can easily achieve task of creating a difference between two entity sets.
Published at DZone with permission of Pranay Rana , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
{{ parent.title || parent.header.title}}
{{ parent.tldr }}
{{ parent.linkDescription }}
{{ parent.urlSource.name }}