【发布时间】:2011-08-22 15:45:41
【问题描述】:
我不明白为什么这个查询会失败。
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;
或者这个:
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 ;
两者都给我这个错误:
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.
谁能帮帮我?
【问题讨论】:
-
.NET 3.5 下的 EF 很烂。迁移到 .NET 4.0,您的问题就会消失。
-
EF 总的来说很烂,但他不需要升级来解决这个问题。
标签: c# .net linq entity-framework .net-3.5