473,385 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

A simple question about foreach using result from linq

Hello!

I have the code below. In the previous code not shown below I have used linq
to extract some row and
these have been placed in the var variable result. In my code there is just
one entry in result but it can be more.
All works fine the first time I enter the following foreach loop
foreach(var o in result)
{
o.ID = nextParamID.ToString();
o.WorksheetRowID = item.WorksheetRowID;
ccrFormObj.myWorksheetRowParameterList.Add(o);
nextParamID++;
}

but when I enter this same foreach loop the second time
the collection result is empy. How is that possible I haven't removed any
entry
in that collection.

My logic in the progam is to use this collection set result when I
enter this foreach loop
foreach(var o in result)
{
o.ID = nextParamID.ToString();
o.WorksheetRowID = item.WorksheetRowID;
ccrFormObj.myWorksheetRowParameterList.Add(o);
nextParamID++;
}

//Code start here
/////////////////////////
for (int i = 0; i < myParamRowCount; i++)
{
WorksheetRowParameter item = ccrFormObj.myWorksheetRowParameterList[i];
//If we have a change in the actual worksheetRowID we might have to do
something
if (item.WorksheetRowID != previousWorksheetRowID)
{
//Check if we have reached a parameter row that is the next
parameter initiator
//If true we have not reached this row so add parameter initiatorer
if (Convert.ToInt32(item.WorksheetRowID) <
workSheetIDListArray[index+1])
{
//We must add parameterinitiator rows because this procedure
require
//that parameter initiators must be repeated
//result is a worksheetRowParameter and contain all the
parameter initiatorer
//for the first row
foreach(var o in result)
{
o.ID = nextParamID.ToString();
o.WorksheetRowID = item.WorksheetRowID;
ccrFormObj.myWorksheetRowParameterList.Add(o);
nextParamID++;
}
}
}
previousWorksheetRowID = item.WorksheetRowID;
}
Can you give me some advice what I should do to keep this result as it is
without being cleaned.

//Tony

Oct 31 '08 #1
0 1260

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Jax | last post by:
Custom control problem. I'm modding a textbox so that it will always have a "%" sign at the end of it. I have overrided the Text property to account for the "%" value within the textbox and have...
15
by: MuZZy | last post by:
Hi, Consider this: ArrayList al = new ArrayList(); FillList(al); /// NOW TWO SCENARIOS: /// 1. for (int i = 0 ; i < al.Count ; i++)
5
by: L C | last post by:
Hello, Could someone point in the correct direction with regards to displaying my data in "nicer" format. I have figured out ( with the tutorials on the web, and the O'Reilly PHP & MySQL book)...
6
by: SuperFool | last post by:
This has got to be one of those questions only a serious newbie would come up with.... Basicly: I select all the city names in the table and turn them into a pull down menu (code below) print...
8
by: Andrus | last post by:
Code below causes error in class definition line .....Isolator<T>' does not implement interface member 'System.Collections.IEnumerable.GetEnumerator()'. 'Myapp.Isolator<T>.GetEnumerator()'...
9
by: =?Utf-8?B?cmF1bGF2aQ==?= | last post by:
Hi all: after reading different places/sites about linq... I ran into these questions: 1. What framework do we need to run linq ? (does it depend on what version of visual studio we have?) how...
3
by: =?Utf-8?B?SmFtZXMgUGFnZQ==?= | last post by:
Hi all Having a mental block with linq! I have a simple aspx page with a button and a label. When the button is clicked I want the label to display the result of a simple query: i.e. Select...
10
by: Tony Johansson | last post by:
Hello! If I have this simple linq construction var temp = from o in myWorksheetList where o.ID == workSheetID select o.subFileID; This will always give only a singe record in temp which is...
2
by: shapper | last post by:
Hello, I have the following method: public static IEnumerable GetRoles(CultureInfo culture, bool open) { switch (culture.TwoLetterISOLanguageName.ToLower()) { case "en": return new { new {...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.