我是LINQ的新手,所以我很困惑這裏。我有一個數據庫,並嘗試運行以下代碼。LINQ to Entities不識別方法'布爾包含[Decimal]
IQueryable<decimal> location_ids = (from m in _db.Admins
where m.UserId.Equals("c5d3dc0e-81e6-4d6b-a9c3-faa802e10b7d")
select m.LocationId);
if (!location_ids.Contains(new Decimal(conf.umisteni.Budova.ID)))
在if語句我得到一個錯誤,我不明白,我也不知道,如何解決這個問題:
System.NotSupportedException: LINQ to Entities does not recognize the method 'Boolean Contains[Decimal](System.Linq.IQueryable`1[System.Decimal], System.Decimal)' method, and this method cannot be translated into a store expression.
at System.Data.Objects.ELinq.ExpressionConverter.MethodCallTranslator.DefaultTranslator.Translate(ExpressionConverter parent, MethodCallExpression call)
任何想法?
您可以用Any()代替.Count()== 0 – 2009-08-31 11:53:15
可以且應該! – 2009-08-31 13:06:54
根據流行的請求:-) – 2009-08-31 13:22:46