Linq to SQL Intersect help needed
Posted
by mohang
on Stack Overflow
See other posts from Stack Overflow
or by mohang
Published on 2010-06-10T15:08:56Z
Indexed on
2010/06/11
7:02 UTC
Read the original article
Hit count: 188
c#
|linq-to-sql
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);
© Stack Overflow or respective owner