This my code. Simplified for readability
var query = from p in people select p;
// here is the point that probably causes the issue
ObjectResult<int> idsThatMatch = getIdsThatMatchFullTextSearch("andre");
query = from p in query where idsThatMatch.Contains(p.id) select p;
var count = query.Count();
query = query.OrderBy(p => p.id);
var pessoas = query.Skip(90).Take(30).ToList();
I need to read the count before skip/take to get the total amount of records before paging. The count works fine. But at the last line of my excerpt it triggers the exception
The result of a query cannot be enumerated more than once
Why? The count isn't supposed to enumerate anything by the way. And how can I solve that? Thank you
EDIT
People thought I was using stored procedures but I'm not. Actually I'm using a "select in". The code is bellow the comment.
EDIT 2
I just tested the above code without the "select in" part and it works fine
EDIT 3
Using this line works:
ObjectResult<int> idsThatMatch = (getIdsThatMatchFullTextSearch("andre");
query = from p in query where idsThatMatch.Contains(p.id) select p).ToArray();
Thank you