LINQ foreach during list creation -


i have simple linq statement builds huge monster list of around 8 billion items. each of items looped through , operation performed on item. problem foreach not run until list created. possible use linq , have execute foreach each item builds instead of waiting?

i not doing in list sorting. straight list building.

edit: may seem wierd, have database rows several numeric values. know arithmetic combination of values yields number want, not sure which. created following linq:

(  i1 in items  i2 in items  i3 in items  i4 in items  select new item[] { i1, i2, i3, i4 } ).tolist().foreach(x => calculatevalues(x); 

i did above statement 1 item 2 items , on. computer hung while @ 3 items 28 million items.

i know inefficient, going quick program run overnight.

don't call tolist() method try load whole data in memory

try this,

var q = i1 in items         i2 in items         i3 in items         i4 in items         select new item[] { i1, i2, i3, i4 };  foreach(var x in q) {     calculatevalues(x); } 

that might still slow input, stream results , process them 1 @ time if correct.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -