473,586 Members | 2,633 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.ToS tring();
o.WorksheetRowI D = item.WorksheetR owID;
ccrFormObj.myWo rksheetRowParam eterList.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.ToS tring();
o.WorksheetRowI D = item.WorksheetR owID;
ccrFormObj.myWo rksheetRowParam eterList.Add(o) ;
nextParamID++;
}

//Code start here
/////////////////////////
for (int i = 0; i < myParamRowCount ; i++)
{
WorksheetRowPar ameter item = ccrFormObj.myWo rksheetRowParam eterList[i];
//If we have a change in the actual worksheetRowID we might have to do
something
if (item.Worksheet RowID != previousWorkshe etRowID)
{
//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.ToInt3 2(item.Workshee tRowID) <
workSheetIDList Array[index+1])
{
//We must add parameterinitia tor rows because this procedure
require
//that parameter initiators must be repeated
//result is a worksheetRowPar ameter and contain all the
parameter initiatorer
//for the first row
foreach(var o in result)
{
o.ID = nextParamID.ToS tring();
o.WorksheetRowI D = item.WorksheetR owID;
ccrFormObj.myWo rksheetRowParam eterList.Add(o) ;
nextParamID++;
}
}
}
previousWorkshe etRowID = item.WorksheetR owID;
}
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 1268

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

Similar topics

6
1604
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 add BaseText to give access to the baseText method too. I have the text_changed event handler wired up to this method, problem is that it works...
15
1351
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
1726
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) how to store, retrieve, manipulate, and display my data using PHP. But when I do display, it is the block format. I can't seem to find a tutorial...
6
2435
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 "<form action=\"update-city.php\" method=\"post\" name=\"theform\">"; print "<SELECT id=\"city\">\n"; while ($row =mysql_fetch_object($result)) {...
8
2530
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()' cannot implement 'System.Collections.IEnumerable.GetEnumerator()' because it does not have the matching return type of 'System.Collections.IEnumerator'....
9
2494
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 about vs2008? is it different name space or framework for linq xml or linq sql? ( 2. do we need to have references to what linq's dlls. or...
3
935
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 name from MyTable where id = 1 This should return ‘peter’ - simplicity using sql I'm trying to do this with linq and getting nowhere (converting...
10
980
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 the result from selct o.subfileID
2
1053
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 { Name = Role.Administrator, Description =
0
7912
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7839
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8216
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6614
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5390
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3837
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3865
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.