我有以下表格:
Monster:
Name Description EatsPeople
Vampire Pale, afraid of light True
Ghost See-through, annoying False
Wraith Green-ish, ugly, dumb True
TagLookup:
Name ID
Ghost 1
Ghost 2
Wraith 1
Tags:
ID Text Value
1 Green green-skin
2 Screams like a banshee banshee-call
要查询具有绿色皮肤标签的怪物,我使用以下 SQL 查询:
SELECT m.Name, m.Description, m.EatsPeople
FROM dbo.Monster AS m
INNER JOIN dbo.TagLookup AS tl
ON m.Name = tl.Name
INNER JOIN dbo.Tags AS t
ON t.ID = tl.ID
AND t.Value = 'green-skin';
正如您所期望的那样,这工作得很好而且很花哨,但是我在使用这个查询的 LINQ 版本时遇到了问题。我试过 LinqPad 没有运气 + 搜索 Bing + Stackoverflow 运气不太好