The method Int32 get Item is not recognized by LINQ to Entities (Int32)

.net entity-framework linq

Question

Entity framework and Linq are new to me. I have a question like that.

var query = (from d in db.MYTABLE
             where d.RELID.Equals(myInts[0])
             select d.ID).Distinct();

List<int?> urunidleri = query.ToList();

The error notice "LINQ to Entities does not recognize the function Int32 get Item(Int32)" appeared when I ran this code. How can I resolve this issue?

Thanks...

1
59
3/8/2011 1:22:49 PM

Accepted Answer

You must keep yourint so that EntityFramework won't attempt to include the whole array in its scope. in a variable.

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();
138
3/8/2011 1:25:42 PM

Popular Answer

var firstInt = myInts[0];
var query = (from d in db.MYTABLE
             where d.RELID.Equals(firstInt)
             select d.ID).Distinct();

List<int?> urunidleri = query.ToList();


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow