Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><code>private string _RemoteSwitchName</code> should be a reference to an actual object rather than a "disconnected" switch name, I think. Then getting the name is like this:</p> <pre><code>protected SwitchConnection RemoteSwitch; this.RemoteSwitch.Name; //need to add "Name" property to the class, of course. </code></pre> <p>This reference will also allow you to traverse through the chain of connections rather easily. This is not mutually exclusive of your idea to query your collection. However finding the "chain" for this given connection will be easier than with LINQ I think. </p> <pre><code> // in SwitchConnection class public List&lt;string&gt; GetAllConnections(List&lt;string&gt; connectionChain) { // to start at any given object just pass in a null reference if (connectionChain == null) { connectionChain = new List&lt;string&gt;; } connectionChain.Add(this.Name); if (this.RemoteSwitch !=null) { RemoteSwitch.GetAllConnections(connectionChain); } return connectionChain; } </code></pre> <p>If you think you are going to have lots of different queries, I'm thinking that a separate class for this will keep your <code>CiscoSwitch</code> and <code>SwitchConnection</code> classes clean. As you learn/experiment with LINQ your "core classes" won't be continually breaking due to LINQ learning mistakes.</p> <p><strong>You'll notice I've not shown any LINQ</strong>. You'll have to get started on your own. But <a href="http://msdn.microsoft.com/en-us/library/bb308959.aspx" rel="nofollow">start simple and be methodical</a>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload