LINQ到实体不能识别方法的Int32 get_Item(Int32)已实体、方法、LINQ、get_Item

2023-09-03 02:19:03 作者:给你脸了是吧、

我是一个对实体框架和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();

当我执行此code,我得到了错误信息LINQ到实体不能识别方法的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();