title: How to use Linq/Lambda with ObservableCollection<T>
body: <p>I have the following code that simply loops looking for a condition and places all matches into a new collection:</p>
  
  <pre><code>ObservableCollection&lt;Device&gt; allDevices = GetAllDevices();
  ObservableCollection&lt;Device&gt; matchingDevices = new ObservableCollection&lt;Device&gt;();
  foreach (Device device in allDevices )
  {
      if (device.ID != 5)
          matchingDevices .Add(device);
  }
  </code></pre>
  
  <p>Pretty simple.  I tried to convert this into a Lambda statement in conjunction with Linq extention methods, but it's failing:</p>
  
  <pre><code>var matchingDevices = (ObservableCollection&lt;Device&gt;)allDevices.Where(d =&gt; d.ID != 5); 
  </code></pre>
  
  <p>This fails because it can't do the cast.  I tried appending .ToList(), but same problem occurred.  It sounds like this should be simple, but I can't find the answer.  </p>