LINQ Recursion - Getting All Items For Specific System?

Dec 3, 2010

I have a situation where I have a hierarchy. I'm trying to use LINQ to get all of the items throughout the hierarchy as opposed to For Each loops. I spent some time looking for examples, but most where C# using lambdas, and I'm not quite sure I understand it. I'd like to try to get all of the Items for a specific system, the levels of items could be n-levels deep.

Code:
System
SubSystem1
Item1
Item99
Item100
Item2
Item121
Item3
SubSystem2
Itemx
Itemy
Itemz

View 6 Replies


ADVERTISEMENT

VS 2010 - Recursion Error With Checked Menu Items

Feb 13, 2012

I've got a menu with checkable items that appears on two different forms, and I'm making sure the two forms always have the same check states, so Form1 would have something like this:

Private Sub mnuWarnings_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuWarnings.CheckedChanged
'when one of these is checked, the other should also be

[code].....

But that yields this error:

An error occurred creating the form. See Exception.InnerException for details. The error is: An error occurred creating the form. See Exception.InnerException for details. The error is: The form referred to itself during construction from a default instance, which led to infinite recursion. Within the Form's constructor refer to the form using 'Me.'

There definitely aren't any references to Form1 within Form1.It only occurs when I use CheckedChanged--if I use mnuWarnings.Click, it works fine. And it only occurs in Form1 (the main form); CheckedChanged works fine on Form2.

View 1 Replies

Convert An Object System.Data.Linq.DataQuery To System.Linq.IQueryable?

Oct 21, 2009

How can I convert an object of type System.Data.Linq.DataQuery to System.Linq.IQueryable?I'm working with Visual Basic/Silverlight, and the source code of my query is as follows:

Public Function Get_Cli_Pag() As IQueryable(Of V_Cliente_Pagare)
Dim Qry = From P In Me.Context.Pagares Join C In Me.Context.Codigos On C.Codigo

[code]....

View 1 Replies

VS 2008 - Linq Statement To Go Through A Dropdown Menu's Sub Items And Get What Items Are Checked

Apr 8, 2010

I have the following linq statement to go through a dropdown menu's sub items and get what items are checked: vb Dim UnselectedItems = From xItem As ToolStripMenuItem In tsiSelectObjects.DropDownItems Where TypeOf xItem Is ToolStripMenuItem AndAlso CType(xItem, ToolStripMenuItem).Checked = False

I get this error tho: Unable to cast object of type 'System.Windows.Forms.ToolStripSeparator' to type 'System.Windows.Forms.ToolStripMenuItem'. As you can probably guess i have ToolStripMenuItems and separators in there

However the AndAlso should short circuit in the case where the item is not a ToolStripMenuItem and it doesn't seem to be doing so (as TypeOf xItem Is ToolStripMenuItem=false in this case)?

View 2 Replies

.net - The System.Linq.Dynamic Namespace - Visual Studio Does Not Recognize In The Project Files The System.XXX References

Aug 11, 2011

I would use the System.Linq.Dynamic. I added the specified Dynamic.vb file, that starts like this:

[Code]...

to my (VB.NET)solution. Now Visual Studio does not recognize anymore in the project files the System.XXX references, proposing me to change them to Global.System.XXX

View 1 Replies

Cannot Convert System.Xml.XmlNode To System.Xml.Linq.XElement

Nov 24, 2010

I´m gettin the error Calling the fuction GetListItems but is kind weird because it works in Visual Studio 2008 Express but no in Visual Basic 2010 Express:

Dim ndQuery As XmlNode = xmlDoc.CreateNode(XmlNodeType.Element, "Query", "")
Dim ndViewFields As XmlNode = xmlDoc.CreateNode(XmlNodeType.Element, "ViewFields", "")
Dim ndQueryOptions As XmlNode = xmlDoc.CreateNode(XmlNodeType.Element,

[Code].....

View 1 Replies

Error: 'System.InvalidOperationException' (LINQ, System.Core.dll)?

Mar 20, 2012

What in this block of code would throw this exception?

'Get Highest Revision Number
If MyExtract_BTR.RevisionBlocks.Count > 1 Then
Try

[code].....

View 1 Replies

Error - LINQ To Entities Does Not Recognize The Method 'System.Object IIf(Boolean, System.Object, System.Object)'

Jul 29, 2011

I am getting following error whenever I want to use IIf function inside entity framework query.

LINQ to Entities does not recognize the method 'System.Object IIf(Boolean, System.Object, System.Object)' method, and this method cannot be translated into a store expression.

View 1 Replies

"System.ArgumentException: An Item With The Same Key Has Already Been Added." When Trying To Order An In-memory LINQ Query By A LINQ Association?

Jan 27, 2011

We are doing a query against an in-memory collection of LINQ data objects. The wrinkle is that we are ordering by a column in a related table whose records have not necessarily been loaded yet (deferred loading:)

Dim oPkgProducts = _
From b In oBillPkg.BillProducts _
Where b.Successful.GetValueOrDefault(Common.X_INDETERMINATE) = _

[code]....

View 1 Replies

Visual Studio's "Unused References..." Button Not Flag System.Xml And System.Xml.Linq?

Feb 18, 2011

I was trying to finish up a VB.NET class library project when I tried to remove all unused references. I know for a fact that I'm not explicitly using any thing from the System.Xml and System.Xml.Linq assemblies yet the "Unused References..." button never flags them for removal.In fact I even tried "Unused References..." on a blank project and it still never flagged them.

View 1 Replies

C# - Give A Specific Name To Column In Linq

Oct 18, 2011

I have following query,

[Code]....

how to do it in linq queries ??? also is it possible to combine firstName and lastname in select query in Linq ? just like we do in SQL Queries like : select me_first_name + ' ' + me_last_name as 'Full Name' from me_employee how can i achieve this task in linq?

View 3 Replies

Sum Up Specific Columns In Gridview Using Linq?

Mar 19, 2012

how to sum upan specific columns in gridview using linq? I can't find anything in Google regarding this topic.

I tried this but not exactly what I want to be the output.

Dim total = Aggregate rowItems In Gridview1.Rows _
Into Sum(Cdbl(rowItems("AMOUNT")))

View 3 Replies

LINQ To SQL: Unable To Cast Object Of Type 'System.Guid' To Type 'System.String'

Nov 15, 2011

I am getting a really bizarre error and it makes no sense at all.Basically I have a user entity which has a Password property. This property is of Type Binary, the server data type being Binary(512).I am reading this value in and converting it to a byte array. However whenever I run my code I am getting a completely unrelated error of Unable to cast object of type 'System.Guid' to type 'System.String'.This strikes me as very odd since I am not using a property or variable of type string or GUID anywhere in this procedure where it falls over.

The code is below:

Public Shared Function ValidateUser(ByVal username As String, ByVal password As String) As UserValidationMessage
Using db As New EntityMapDataContext
Dim u = From user In db.Users
Where user.Username = username

[code]....

View 3 Replies

Pass Content To Specific Record In XML Using LINQ?

Nov 14, 2009

I am using the following line of LINQ to drill down into an element. Is it possible to expands this code to drill further down so that I can add content to the <population> element in "Test2". I want to be able to do somthing like element.SetValue(1000000). However I need to expand the code below so that I can pass the entire query results into the variable called "element"'

Dim eles = From c In doc.Descendants("File") _
Where c.Attribute("Name").Value = "Test2" _
Select c

[code]....

View 3 Replies

Update Specific Rows In LINQ To SQL Result Set

Apr 6, 2010

I have a page with a form on it and needs a range of dates. Thus I've placed a number of textboxes on the page into which users can type dates. When the user clicks the save button I want to trigger a LINQ update to the SQL Server...all the rows already exist, so I'm just updating existing data.

For example, lets say my table looks like this:
Column Names: Description dateValue
Column Values:
Birthdate 1/1/1990
Anniversary 1/10/1992
Death 1/1/1993

I want to do something like this:
hupdate.Description("Birthdate").dateValue = TextBox1.Text
hupdate.Description("Anniversary").dateValue = TextBox2.Text
hupdate.Description("Death").dateValue = TextBox3.Text
hconfig.SubmitChanges()
Is there a way to do this with LINQ?

View 1 Replies

.net 3.5 - Recursion With XML Literals?

Jul 28, 2009

I have a class called Profile that has some simple properties and then it can have a collection of ProfileItem that again has some simple properties and then it can have a collection of ProfileItem (RECURSION). Now I am trying to generated a very simple save function using XML Literals that come with VB.NET (3.5).

[Code]....

View 1 Replies

Is It A Recursion Call

Oct 16, 2010

The code is from a text book.[code]SetProgress is referenced within SetProgress, I don't understand it.Is it a recursion call?

View 4 Replies

Access Specific Listbox Items?

Jun 25, 2012

I am trying to access a specific item in a listbox. For example, I have 5 items in a list box and I need each one on a different textbox, but I cannot find the code necessary to access a individual item in a listbox. I need the third item in a textbox but I cant find the code to access that SPECIFIC item and turn it into text in the texbox.

View 2 Replies

Add Items To A Listview In A Specific Order?

Apr 18, 2012

If Not m_Batchs Is Nothing Then[code]...

I have this list view (which is working fine) and i want to find an efficient way of populating it in a specific order, ie by date, by identity etc.

I know i can use linq but as i understand this is inefficient. If m_batchs is a large list of objects then i will looping through this list many, many time (as linq behind the scenes loops through the object collection).

View 1 Replies

How To Add All Items Of Specific Column Of ListView

Aug 19, 2010

How can I add all the items of a specific column of a listview. For example I had a listview of a class like:

name............... surname............... age
------------------------------------------------
asdsa..............asdasdasd................21
sadsad..............asdasdasd...............23
sadsad...............adasdasd...............24

I just want to add all the numbers of age column so I can find the total sum of ages of the students. I want, when I clicked my button It makes my textbox's text = 68 for this example.

View 3 Replies

How To Select Specific Items From A List

Sep 28, 2010

I am working with a list of points. It is declared as a global in my form.[code]the only issue is that instead of New Point(100,100) i need to be able to navigate to the previous 4 records in the list. pull out the 4 x vals the 4 y vals and boom there you go. In the old days id make a simple loop and get r done but im not sure the syntax to step through the list that way.

View 8 Replies

C# - Pick Out A Group Of Items Using Linq To Xml

Jul 4, 2011

My head is fuzzled with this. I have an xml doc which has the layout for a grid stored in it. If you notice the columns are stored as "Items" in the XML. I am trying to retrieve each "Item" out of the XML using LINQ but no matter what I do I keep taking on straggler properties that I don't need.

[Code]...

View 1 Replies

Linq Group Count Items?

Dec 5, 2011

I have this linq to entity

From r In ReceiptRepository.Fetch
Where
r.RECEIPTDATE >= ReportStartDate And

[Code]....

This is working fine, except the count property, it is just giving the number of group count. I don't know how to find out each Tender Count

View 1 Replies

Linq Partial Sorting Items?

Aug 19, 2011

I have an issue for ordering items using Linq[code]...

View 4 Replies

Recursion Error Down To One Subroutine

Jun 21, 2012

I've tracked a recursion error down to one subroutine, So when my form loads, it populates some listboxes from a database; any one of these causes the error:
ListboxQuery("select sculptname, sculptid from sculptures;", CloseSculptList, "sculptname", "sculptid")
ListboxQuery("select distinct eventtype from events;", EventTypeList, "eventtype", "eventtype")
'etc, etc

And here's the subroutine (it's querying a MySQL database):
Public Sub ListboxQuery(ByVal queryText As String, ByVal resultObject As Object, ByVal resultDisplay As String, ByVal resultValue As String)
'queries the database for a 1- or 2-column list of values to display in a listbox
Dim myCommand As New MySqlCommand
Dim myAdapter As New MySqlDataAdapter
[Code] .....

The error is the standard recursion error:
An error occurred creating the form. See Exception.InnerException for details. The error is: The form referred to itself during construction from a default instance, which led to infinite recursion. Within the Form's constructor refer to the form using 'Me.'

This is weird for two reasons: One, as you can see, the subroutine doesn't refer to the form at all, so I don't see how it could cause a recursion error, and two, I wrote this subroutine almost a year ago and it only caused this error last week.

View 10 Replies

Counting Specific Items In One Dimensional Array

Feb 10, 2011

I have one dimensional array that is being returned by an NVP function, the problem is that I want to count the number of ID's returned by the array to set the limit. For instance the array comes in this format ID0, ID1, ID3.... IDn, Name0, Name1, ...., Namen, Surname0, surname1, ...., surnamen etc... I want to know the n+1 number of ID's so that I can set it as the upper limit of my array to be able to loop through without setting an arbitrary number.

View 2 Replies

Delete Specific Items From A Series Of Files?

Oct 14, 2009

I have a series of files in different folders. Is there any way to open these files automatically search for lines containing fullBod and delete them completely? Then, close the file and save the changes? This tool should be able to process several files at once in a directory. clock [t= 83] SetSwitch [figure= fullBod switch= walk_across state= 01]

View 3 Replies

Drop Items Into Specific Group In A Listview?

Jul 12, 2010

I'm trying to drag an item between two Groups in the same ListView called 'listTasks'.

Private Sub listTasks_ItemDrag(ByVal sender As Object, ByVal e As ItemDragEventArgs) Handles listTasks.ItemDrag
listTasks.DoDragDrop(listTasks.SelectedItems, DragDropEffects.Move)
End Sub
Private Sub listTasks_DragEnter(ByVal sender As Object, ByVal e As DragEventArgs) Handles listTasks.DragEnter

[Code]...

With listTasks.PointToClient(New Point(e.X, e.Y)) you could use listTasks.GetItemAt(p.X, p.Y) to get the ListView item you're over. Is there something like this for Groups? Or perhaps a better way to determine what group is the target of a drag-drop?

View 1 Replies

[2008] Add Some Items Into A Specific ColumnHeader In ListBox1?

Mar 9, 2009

i'm trying to add some items into a specific ColumnHeader in ListBox1. If i have 3 columns, and i want to add the information written in Textbox1 to ColumnHeader2, how can i do it?

I add using:

ListView1.Items.Add("blah blah blah")

But that adds it into the first column...

View 8 Replies

C# - Linq To XML Query Creating Empty Items From XML

Feb 15, 2010

why is this xml

<?xml version="1.0" encoding="utf-8"?>
<items>
<item id="77" cityID="EE12345" cityDatum="15.2.2010. 11:28:35" />
</items>

[Code]....

If you, as some can't replicate these results, here's a screenshot:

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved