Linq to SQL Intersect help needed
- by mohang
Hi,
I have tried various suggestions given in SO. I still did not get the answers needed. Kindly help me. I appreciate your help.
I have two sets.
I need help to get the linq to sql intersection done. I have two sets.
IQueryable<BusinessEntity> firstSet = from ent in all entities where ... // Code to get the first set.
IQueryable<BusinessEntity> secondSet = from ent in all entities where... // Code to get the second set.
Now I want the intersection, that is common elements of these sets.
I have tried various ways including the following and I did not get the result I wanted. Please help me to get the right result.
var commonEntities = (from ent1 in firstSet
from ent2 in secondSet
where ent1.BusinessEntityId == ent2.BusinessEntityId
select ent1);