I was under the impression that I could create a LINQ query and then reuse it while change the parameters involved. But it seems that you cant change the source collection. Can someone give me a good explanation as to why, as I have clearly misunderstood something fundamental.
Here is some example code.
var source = Enumerable.Range(1, 10);
var value = source.Where(x => x > 5);
var first = value.ToArray();
source = Enumerable.Range(11, 20);
var second = value.ToArray();
I was expecting first to be 6,7,8,9,10 and second to be 11 to 20.
When you do:
You are creating a new object. However, the
Wherequery still has a reference to the old object.