LINQ subquery “NOT IN” problem

后端 未结 2 1378
庸人自扰
庸人自扰 2021-01-06 10:49

I do not understand why this query fails.

var qTags = from tagsU in _context.ADN_ProductTagsView
where !(from o in _context.ADN_ProductTagsView
        where         


        
相关标签:
2条回答
  • 2021-01-06 11:05

    Try .Any

    var qTags = from tagus in _context.ADN_ProductTagsView
                where !tagAux.Any(t=> t== tagus.ProductTagID)
                select tagus ;
    

    btw, did not run the query, so please check the syntax.

    0 讨论(0)
  • 2021-01-06 11:07

    It seems that the implementation of the QueryProvider you're using isn't complete. I'm not familiar with the QueryProvider you're using, but maybe you can try something like this:

    var qTags = from tagsU in _context.ADN_ProductTagsView
    where !(from o in _context.ADN_ProductTagsView
            where o.ProductID == productId
             select o.ProductTagID).Any(tagId => tagId == tagsU.ProductTagID)
    select tagsU;
    

    Hope that helps

    0 讨论(0)
提交回复
热议问题