LINQ to Entities 无法识别方法 Int32 get_Item(Int32) [英] LINQ to Entities does not recognize the method Int32 get_Item(Int32)
本文介绍了LINQ to Entities 无法识别方法 Int32 get_Item(Int32)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是实体框架和 linq 的新手.我的查询就是这样
I am a newbie about entity framework and linq. My query is like that
var query = (from d in db.MYTABLE
where d.RELID.Equals(myInts[0])
select d.ID).Distinct();
List<int?> urunidleri = query.ToList();
当我执行此代码时,我收到错误消息LINQ to Entities 无法识别方法 Int32 get_Item(Int32)".我该如何解决我的问题?
When i execute this code, i got the error message "LINQ to Entities does not recognize the method Int32 get_Item(Int32)". How can i solve my problem ?
谢谢...
推荐答案
您需要将 int
存储在一个变量中,这样 EntityFramework 就不会试图将整个数组拉入其作用域.
You need to store your int
in a variable, so that EntityFramework isn't trying to pull the whole array into its scope.
var myInt = myInts[0];
var query = (from d in db.MYTABLE
where d.RELID.Equals(myInt)
select d.ID).Distinct();
List<int?> urunidleri = query.ToList();
这篇关于LINQ to Entities 无法识别方法 Int32 get_Item(Int32)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文