2

我正在尝试在 on 子句中使用两个条件连接表,但出现错误

运算符 && 不能应用于 byte 和 byte 类型的操作数

如何在 ON 子句中使用多个条件来连接表?

                    using (var db = new ReleaseInfo())
                {
                    lvReleaseInfo = (from r in db.ReleaseTranslations
                                     join c in db.Countries
                                     on r.SectionRelease.ReleaseCountryID equals c.CountryID && c.CultureID equals CultureID
                                     join pf in db.Platforms
                                     on r.SectionRelease.PlatformID equals pf.PlatformID && pf.PlatformID equals CultureID
                                     join pub in db.Publishers
                                     on r.SectionRelease.PublisherID equals pub.PublisherID && pub.CultureID equals CultureID
                                     where r.ReleaseID == SectionID && r.CultureID == CultureID
                }
4

1 回答 1

1

您可以为 equi-join 的每一侧创建一个匿名类型:

lvReleaseInfo = (from r in db.ReleaseTranslations
                 join c in db.Countries
                 on new {CountryID = r.SectionRelease.ReleaseCountryID, CultureID} equals new {c.CountryID, c.CultureID}
                 join pf in db.Platforms
                 on new {r.SectionRelease.PlatformID, CultureID} equals new {pf.PlatformID, CultureID = pf.PlatformID}
                 join pub in db.Publishers
                 on new {r.SectionRelease.PublisherID, r.CultureID} equals new {pub.PublisherID, pub.CultureID}
                 where r.ReleaseID == SectionID && r.CultureID == CultureID
于 2013-03-21T01:53:09.703 回答