Reputation: 19
Can anyone convert this to LINQ?
select distinct t.Product_ID from Product as t
join Product_UserQuestionaire as s
on t.Product_ID = s.Product_ID where t.Product_ID not in (
select distinct t.Product_ID from Product as t
join Product_UserQuestionaire as s
on t.Product_ID = s.Product_ID
where s.SpaceID =7 )
Upvotes: 2
Views: 229
Reputation: 13458
When having problems with LINQ try breaking down the subqueries into IQueryable statements. These don't execute unless you hit .ToList or enumerate the results, so it's a good way to separate out the logic of the query.
However in this case the SQL query is over-complicated:
var query = (from t in Product
join s in Product_UserQuestionaire on t.Product_ID equals s.Product_ID
where s.SpaceID != 7
select t.Product_ID).Distinct();
Upvotes: 1