我试图在我的on子句中使用两个条件来连接表,但是我得到了错误
运营商&&不能应用于字节和字节类型的操作数
如何在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
}
答案 0 :(得分: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