Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Because the <code>BindingListView&lt;T&gt;</code> project uses .NET Framework v2.0 and predates LINQ, it doesn't expose an <code>IEnumerable&lt;T&gt;</code> for you to query on. Since it <strong>does</strong> implement non-generic <code>IEnumerable</code> and non-generic <code>IList</code>, you can use <code>Enumerable.Cast&lt;TResult&gt;</code> to convert the collection into a form suitable for use with LINQ. However, this approach isn't that helpful because the <code>IEnumerable</code> that <code>AggregateBindingListView&lt;T&gt;</code> returns is an internal data structure with type <code>KeyValuePair&lt;ListItemPair&lt;T&gt;, int&gt;</code>.</p> <p>To upgrade this project for convenient use with LINQ, the simplest approach might be to implement <code>IEnumerable&lt;T&gt;</code> on <code>AggregateBindingListView&lt;T&gt;</code>. First add it to the declaration of the class:</p> <pre><code>public class AggregateBindingListView&lt;T&gt; : Component, IBindingListView, IList, IRaiseItemChangedEvents, ICancelAddNew, ITypedList, IEnumerable&lt;T&gt; </code></pre> <p>and then implement it at the end of the class definition:</p> <pre><code>#region IEnumerable&lt;T&gt; Members IEnumerator&lt;T&gt; IEnumerable&lt;T&gt;.GetEnumerator() { for (int i = 0; i &lt; _sourceIndices.Count; i++) yield return _sourceIndices[i].Key.Item.Object; } #endregion </code></pre> <p>and now you can use LINQ directly on a <code>BindingListView&lt;T&gt;</code> instance like this:</p> <pre><code>// Create a view of the items itemsView = new BindingListView&lt;Item&gt;(feed.Items); var descriptions = itemsView.Select(t =&gt; t.Description); </code></pre> <p>Remember to upgrade all the projects from .NET Framework v2.0 to .NET Framework 4 Client Profile and add <code>using System.Linq;</code> in order for this to work with your current project.</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