Subsonic 2.2 无法弄清楚如何进行连接

发布于 2024-09-07 09:07:00 字数 1503 浏览 4 评论 0原文

我对亚音速很陌生,我正在尝试通过大量连接进行一个非常棒的查询。 我可以用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浅浅 2024-09-14 09:07:00

默认情况下,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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文