I have a problem with looping through a set of XElements
. The behavior is not what I expected.
A short re-written version of my code, so you can easily get my problem (console app in C#)
IEnumerable<XElement> q = from c in xml.Descendants(aw + "wd")
where (....)
select c;
...
//--------------------------------------------------------------------
IEnumerable<XElement> currRow = q.OrderBy(yyy => (int)yyy.Attribute("t"));
int xValue = 10;
currRow = currRow.Where(yyy => (int)yyy.Attribute("t") < xValue);
xValue = 20;
//Here, the currRow gets a new value automatically. I don't want this!
//--------------------------------------------------------------------
//This is want i want to acheive:
IEnumerable<XElement> currRow = q.OrderBy(yyy => (int)yyy.Attribute("t"));
int xValue = 10;
currRow = currRow.Where(yyy => (int)yyy.Attribute("t") < xValue);
//do somthing with currRow
xValue = 20;
currRow = currRow.Where(yyy => (int)yyy.Attribute("t") < xValue);
//do somthing else with currRow
xValue = 30;
currRow = currRow.Where(yyy => (int)yyy.Attribute("t") < xValue);
// etc....
Any ideas?