Click here to Skip to main content
15,886,079 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am trying to get some data using Linq to sql
But getting the error "The LINQ expression node type 'ArrayIndex' is not supported in LINQ to Entities."in code below.
C#
Tab[] items = db.Tabs.Where(c => c.PortalID == 32 && c.ParentID == 1983).ToArray<tab>();

But when I changed the where condition like below , the code is working.
C#
Tab[] items = db.Tabs.Where(c => c.PortalID == 32 ).ToArray<tab>();

There is no data in db for the first condition, but data is there for the second condition.
How can i check whether there is some data returning from db?
Posted
Updated 15-Sep-15 0:08am
v2
Comments
DamithSL 15-Sep-15 6:33am    
is this the exact code you get above exception? how you get ParentID value?
deepankarbhatnagar 15-Sep-15 8:45am    
Please explain with proper code
George Swan 15-Sep-15 17:19pm    
My guess is that Linq to Entities tries to convert the query into a SQL statement but this fails because of the ToArray() call. You need to return an enumerable and then convert that to an array. I suspect that the only reason that your second example appears to work is that there is no data to be returned.

1 solution

Based on this piece of code no one can help you. So, i'd strongly recommend to read these articles:
LINQ to Entities[^]
Known Issues and Considerations in LINQ to Entities[^]
Supported and Unsupported LINQ Methods (LINQ to Entities)[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900