我需要在 LINQ to Entities 中模仿这一点:
WHERE
(title = 'title1' AND episodetitle = 'episodetitle1')
OR
(title = 'title2' AND episodetitle = 'episodetitle2')
我试过这个:
if (title1 != null && episodeTitle1 != null)
{
query = query.Where(s => s.Title.Contains(title1)).Where(z => z.EpisodeTitle.Contains(episodeTitle1));
}
if (title2 != null && episodeTitle2 != null)
{
query = query.Where(s => s.Title.Contains(title2)).Where(z => z.EpisodeTitle.Contains(episodeTitle2));
}
但它给了我这个:
([Extent1].[Title] LIKE @p__linq__0 ESCAPE '~') AND ([Extent1].[EpisodeTitle] LIKE @p__linq__1 ESCAPE '~')
**AND**
([Extent1].[Title] LIKE @p__linq__2 ESCAPE '~') AND ([Extent1].[EpisodeTitle] LIKE @p__linq__3 ESCAPE '~')}
我需要将上面的AND更改为 OR。
我该怎么做呢?