title: VB.net Datatable dynamic columns Query fields with LINQ
body: <p>For a project i'm trying to make a dynamic query to a datatable field.
  Let me explain what i'm doing. 
  Step 1. Read database file with OLEDB and create snapshot to datatable.
  Step 2. Create dynamically checkboxes that represents the field names from the datatable.
  Step 3. User can create query by selecting the checkboxes. Thus filtering the result.</p>
  
  <p>The problem that i'm having is that i don't know upfront how many and what name's the Fields/Column are getting in the datatable. It is no problem making the query if i fill in the Field names hardcoded:</p>
  
  <pre><code> MyDataview = (From p In MyDataTable _
                        Where p.Field(Of Boolean)("customer") = True And _
                              p.Field(Of Boolean)("customer_ID") = True
                              Select p).AsDataView
  </code></pre>
  
  <p>However this would be a problem in the future as the database therefore datatable could change and expand or shrink.</p>
  
  <p>So in SQL syntax this wouldn't be any problem. Simple append the field name that correspondent with the checkbox to a Where clause and where good to go.</p>
  
  <p>This is exactly what i'm trying to achieve. I have searched for many hours and tried allot with system.linq.dynamic but i can't get it to work. example:</p>
  
  <pre><code>        Dim valueQuery = MyDataTable.AsEnumerable.Where("customer").[Select]("customer")
  
          causes exception: 
          No property or field 'customer' exists in type 'DataRow' 
  </code></pre>
  
  <p>Or</p>
  
  <pre><code>Dim valueQuery = MyDataTable.AsEnumerable.Where("Field=customer").[Select]("customer")
  </code></pre>
  
  <p>causes exception: </p>
  
  <blockquote>
    <p>No property or field 'customer' exists in type 'DataRow'</p>
  </blockquote>