Reputation: 55
I've this query in my C# file and it works fine:
from var in db.database_1
where var.database_2.primarycat.Length > 0 && var.meditype.Contains("All")
xxx
select new XElement("id", new XElement("temp", var.database_2.name)
Now, I want to insert this query in the where argument at xxx:
AND name IN (
SELECT primarycat
from database_2
GROUP BY primarycat
HAVING COUNT(*) > 1)
Can somebody help me?
Upvotes: 4
Views: 182
Reputation: 7906
Use a sub select. Check out this thread which answers pretty much the same thing.
Upvotes: 1
Reputation: 3972
A simple sub query should do this:
from var in db.database_1
where var.database_2.primarycat.Length > 0
&& var.meditype.Contains("All")
&& (from cat in db.database_2
group cat by cat.primarycat into g
where g.Count() > 1
select g.Key).Contains(var.name)
select new XElement("id", new XElement("temp", var.database_2.name)
Upvotes: 5