6
我在LINQPad中測試了以下查詢,它運行良好,但VS2010不喜歡它。Linq查詢中的'IN'和'NOT IN'
var topJobs = from j in streetlightDBEntities.Job
let mjobid = from m in streetlightDBEntities.Job.Include("Streetlight")
where m.Streetlight.StreetlightId == j.Streetlight.StreetlightId
orderby m.DateCompleted descending
select m.JobId
where mjobid.Take(5).Contains(j.JobId)
select j.JobId;
var notTopJobs = streetlightDBEntities.Job.Where(c => !topJobs.Contains(c.JobId));
我得到了以下錯誤:
LINQ to Entities does not recognize the method 'Boolean Contains[String](System.Linq.IQueryable`1[System.String], System.String)' method, and this method cannot be translated into a store expression.
您的目標是.NET 3.5還是.NET 4.0? – DamienG 2010-11-29 05:48:20
vs 2010 .NET 4.0 – Kiddo 2010-11-29 22:12:01