小编Her*_*cko的帖子

LINQ子查询“ NOT IN”问题

我不明白为什么这个查询失败。

var qTags = from tagsU in _context.ADN_ProductTagsView
where !(from o in _context.ADN_ProductTagsView
        where o.ProductID == productId
         select o.ProductTagID).Contains(tagsU.ProductTagID)
select tagsU;
Run Code Online (Sandbox Code Playgroud)

或者这个:

var tagAux = from o in _context.ADN_ProductTagsView
             where o.ProductID == productId
             select o.ProductTagID;

var qTags = from tagus in _context.ADN_ProductTagsView
            where !tagAux.Contains(tagus.ProductTagID)
            select tagus ;
Run Code Online (Sandbox Code Playgroud)

两者都给我这个错误:

LINQ to Entities does not recognize the method 'Boolean Contains[Int32](System.Linq.IQueryable`1[System.Int32], Int32)' method, and this method cannot be translated into a store expression.
Run Code Online (Sandbox Code Playgroud)

谁能帮我?

.net c# linq entity-framework .net-3.5

4
推荐指数
1
解决办法
7116
查看次数

标签 统计

.net ×1

.net-3.5 ×1

c# ×1

entity-framework ×1

linq ×1