これは私が欲しいSQLです(ClearinghouseKey
はですbigint
):
select *
from ConsOutput O
where O.ClearinghouseKey IN (
select distinct P.clearinghouseKey
from Project P
Inner join LandUseInProject L on L.ClearinghouseKey = P.ClearinghouseKey
where P.ProjectLocationKey IN ('L101', 'L102', 'L103')
and L.LandUseKey IN ('U000', 'U001', 'U002', 'U003')
)
内部クエリは簡単で、LINQPad で正しい結果が得られます。
var innerQuery = (from p in Projects
join l in LandUseInProjects on p.ClearinghouseKey equals l.ClearinghouseKey
where locations.Contains(p.ProjectLocationKey)
&& (landuses.Contains(l.LandUseKey))
select new { p.ClearinghouseKey }).Distinct();
しかし、外側のクエリではエラーが発生します: Type arguments from ...Contains.. can't be inferred from usage:
var returnQuery = from o in OperOutput
where (innerQuery).Contains(o.ClearinghouseKey)
select o;
ClearinghouseKey が bigint であるためですか? このクエリを記述する他の方法はありますか?
ありがとう、ジャンヌ