Subsonic 2.2 无法弄清楚如何进行连接
我对亚音速很陌生,我正在尝试通过大量连接进行一个非常棒的查询。 我可以用 sql 来做,但真的想用亚音速做,但不知道如何做..
中的查询
这是 SQL SELECT dbo.Job.JobId,
dbo.Job.JobReference,
dbo.Job.Title,
dbo.JobCategory.CategoryId,
dbo.JobOccupation.OccupationId,
dbo.Category.Name
FROM dbo.Job
LEFT OUTER JOIN
dbo.JobType
ON dbo.Job.JobTypeId = dbo.JobType.TypeId
LEFT OUTER JOIN
dbo.Category
INNER JOIN
dbo.JobCategory
ON dbo.Category.CategoryId = dbo.JobCategory.CategoryId
ON dbo.Job.JobId = dbo.JobCategory.JobId
LEFT OUTER JOIN
dbo.Occupation
INNER JOIN
dbo.JobOccupation
ON dbo.Occupation.OccupationId = dbo.JobOccupation.OccupationId
ON dbo.Job.JobId = dbo.JobOccupation.JobId
LEFT OUTER JOIN
dbo.JobSkillLevelRequired
INNER JOIN
dbo.Skill
ON dbo.JobSkillLevelRequired.SkillId = dbo.Skill.SkillId
ON dbo.Job.JobId = dbo.JobSkillLevelRequired.JobId
我的主要问题是在类别和职业表上。 JobCategory和JobOccupation是类别和职业的链接表,每个工作可能有一个或另一个,两个或两个都没有..但我仍然需要带回所有工作,无论它们是否有类别和应用程序。 我不知道如何做到这一点:
INNER JOIN dbo.JobCategory
ON dbo.Category.CategoryId = dbo.JobCategory.CategoryId
ON dbo.Job.JobId = dbo.JobCategory.JobId
有人可以帮忙吗? (我正在使用 c# 顺便说一句)
谢谢
bex
I'm quite new to subsonic and I am trying to do an almight great query with lots of joins..
I can do it in sql but really want to do it in subsonic but cant work out how..
this is the query in SQL
SELECT dbo.Job.JobId,
dbo.Job.JobReference,
dbo.Job.Title,
dbo.JobCategory.CategoryId,
dbo.JobOccupation.OccupationId,
dbo.Category.Name
FROM dbo.Job
LEFT OUTER JOIN
dbo.JobType
ON dbo.Job.JobTypeId = dbo.JobType.TypeId
LEFT OUTER JOIN
dbo.Category
INNER JOIN
dbo.JobCategory
ON dbo.Category.CategoryId = dbo.JobCategory.CategoryId
ON dbo.Job.JobId = dbo.JobCategory.JobId
LEFT OUTER JOIN
dbo.Occupation
INNER JOIN
dbo.JobOccupation
ON dbo.Occupation.OccupationId = dbo.JobOccupation.OccupationId
ON dbo.Job.JobId = dbo.JobOccupation.JobId
LEFT OUTER JOIN
dbo.JobSkillLevelRequired
INNER JOIN
dbo.Skill
ON dbo.JobSkillLevelRequired.SkillId = dbo.Skill.SkillId
ON dbo.Job.JobId = dbo.JobSkillLevelRequired.JobId
My main problem is on the category and occupation tables.. JobCategory and JobOccupation are link tables to category and occupation, each job may have one or ther other, both or neither.. but I still need to bring back all the jobs regardless of whether they have categories and applications.
I can't work out how to do this bit:
INNER JOIN
dbo.JobCategory
ON dbo.Category.CategoryId = dbo.JobCategory.CategoryId
ON dbo.Job.JobId = dbo.JobCategory.JobId
Can anyone help? (i'm working with c# btw)
Thanks
bex
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
默认情况下,SubSonic 2 无法连接多个列。
我不久前偶然发现了这一点:
subsonic 2 join on multiple columns
我总是想实现这个,但我还没有时间更新源代码。
我建议您改用 InlineQuery。
SubSonic 2 can't join on multiple columns per default.
I stumbled upon this a while ago:
subsonic 2 join on multiple columns
I always wanted to implement this but I haven't found the time to update the sources.
I would suggest you use an InlineQuery instead.