简体   繁体   中英

I need help to Convert a SQL Statement to C# LINQ

I need help with Converting this Select statement in LINQ C# Code

SELECT TagName 
from Tags 
Where TagId IN(
    SELECT TagId 
    from PresentationTags 
    Where PresentationId = 2
)

Where() with nested Any() should do the job

context.Tags.Where(
    x => context.PresentationTags.Any(
        y => y.PresentationId == 2 && x.TagId == y.TagId
    )
).Select(x => x.TagName);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM