title: Entity Framework reflection invoke where method of a table, mvc c#
body: <p>Trying to do a reflection call to table and invoke the where method.
  Use in MVC (2), </p>
  
  <p>Data in entity framework. Could hardcode for the currently two tables that im trying to get data out off.</p>
  
  <p>Trouble at how to invoke the where method.</p>
  
  <p>And simply surprised that I did not find answer to this already? So if already answered, and iv not searched the right thing, im sure you'll let me know.</p>
  
  <p>have the following</p>
  
  <pre><code>string search_table
  
  PropertyInfo prop = database.GetType().GetProperty(search_table);
  object table = prop.GetValue(WRG,null);
  var methods = table.GetType().GetMethods();
  
  var where_method = table.GetType().GetMethod("Where");
  var result_data = where_method.Invoke(table, new object[]{"table", "table.-FIELD-NAME.Contains(search_string)"});
  </code></pre>
  
  <p>If not using reflection, then I would call the where method with
      var result_data = database.-TABEL-.Where(t => t.-FIELD.Contains(search_string));</p>
  
  <p>So have tried copping that info into the invoke, nothing.</p>
  
  <p>where invoke asks for: (object obj, object[] parameters)</p>
  
  <p>thank you anyone pointing me in the right direction.</p>