Skip to content
Advertisement

Linq tolist() count returns different value from translated sql

I have a situation where the translated sql direct form Visual Studio is returning a different number of records from the Linq. I am expecting 4 items but in the count() of the resulting list I only have 1. This is the case despite creating more records – it always returns 1.

Strange thing is I have the same linq expression running fine for other entities and there is no problem. It is consistently happening at the same spot every time.

enter image description here

Advertisement

Answer

Is a query of the entire table, not the query for what you want.

If you want to inspect the IQueryable of the full query, try:

Here results should translate as roughly:

Assuming DCLVUnknownId is a PK/ Identity, you should see one result in theResultSet.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement