T-SQL:
declare @postlocations table (locationid int)
insert into @postlocations
select locationid
from dbo.PostLocations
where PostId = 162172
select t.*
from dbo.Themes t
inner join dbo.ThemeLocations tl on t.ThemeId = tl.ThemeId
inner join @postlocations pl on tl.LocationId = pl.locationid
到目前为止,我拥有的 LINQ 实体:
var postLocations = e.SomePost.Locations; // pre-fetched, e.g materialized ICollection<Post>
var themes = (from t in db.Themes
join q in postLocations on t.Locations.Select(l => l.LocationId) equals q.LocationId
select t).ToList();
但是编译器抱怨join
无法推断类型参数的关键字。
有任何想法吗?