Manually select related table data (SELECT N + 1 problem) LINQ to SQL

前端 未结 2 796
别跟我提以往
别跟我提以往 2021-01-18 18:44

Database example:

Image - ImageTag - Tag

Images can have multiple tags. The relationships are set up fine and stuff but I am running into pe

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-18 19:05

    why not try something like:

    return
            from i in qry
            from iTags in i.ImageTags
            where tags.Contains(iTags.Tag)
            select new { TagName = i.Tag.name };
    

    That will return a Collection with only the Tag Names. I hope I'm understanding your question properly here. Hope it helps

提交回复
热议问题