I had a question pertainning to Parelle and Task in this thread. Previous Question Related to this one
What I am attempting to do is iterate over a collection returned from the entity framework via a sproc.
Everything query's perfectly on the first loop but on the second when I try to skip past the previous query results I'm getting an The result of a query cannot be enumerated more than once error.
I realize the debugger is telling me that I cannot page this collection in this fashion.
How do I use .Skip() and not get that error? I need to be able to iterate over the entire collection until the end is reached.
What's the magic to do this?
Like I mentioned I can loop once, but after that I get that error.
HELP!
ObjectResult<Guid?> memIDs = await Task.Run(() => db.proc_GetCollaborator_UserIDs(projectID));
if (memIDs != null)
{
while (true)
{
var t = memIDs.Take(Environment.ProcessorCount)
.Select(id => Task.Run(() => projCollabors.Add(new Collaborator(id.Value, projectID))))
.Skip(skip)
.ToArray();
if (t.Length == 0) { break; };
skip += Environment.ProcessorCount;
await Task.WhenAll(t);
};
};