title: How to apply a filter on LINQtoSQL results?
body: <p>With the ListBox control it is possible to feed it a DataSource, name a DisplayMember and a ValueMember and through some magic it will display a field from the DataSource and return a selected ValueMember. It can work wit a linq-to-sql result without even knowing anyting specific about the table it is feed with.</p>
  
  <p>Isn't Reflection and Attributes doing some magic? How does it work!
  I have a need to do something similar but I do not know where to start. I'm a beginner for LINQtoSQL.</p>
  
  <p>This is what I want to do.
  I have a source table that I want to filter. The source table can be anything but will be originating from some DataContext.</p>
  
  <pre><code>var MySourceTable =
      from MyRecord in Context.GetTable&lt;MySourceTable&gt;()
      select new
      {
          Value = MyRecord.ID,
          Display = MyRecord.Name,
          FilterValue = MyRecord.Value
      };
  </code></pre>
  
  <p>In my control I want to be able to filter MySourceTable on some given value. The control does not know what table is used (MySourceTable in the example above) and the control does only know the three names, ID, Name and Value of the fields in the record it should use.</p>
  
  <p>The filter query should look like the example below.</p>
  
  <pre><code>var MyTable
      from Record in MySourceTable
      where FilterValue == GivenValue
      select new
      {
          Value = Record.ID,
          Display = Record.Name,
      };
  </code></pre>
  
  <p>Can somebody advise me on where to start?</p>