title: How to implement search functionality in C#/ASP.NET MVC
body: <p>I am developing an ASP.NET MVC 3 application using C# and Razor. </p>
  
  <p>I have a search form that looks like this:
  <img src="https://i.stack.imgur.com/VVceA.jpg" alt="searchform"></p>
  
  <p>The search form works in the following way:</p>
  
  <ol>
  <li>The user selects which property they want to search on.</li>
  <li>The user selects how they want to match the search string (e.g. contains, starts with, ends with, equals, etc).</li>
  <li>The user enters a search term and clicks Search.</li>
  </ol>
  
  <p>The selections in the first drop down related directly to a property in my ADO.NET Entity Framework model class (and therefore directly to a table column).</p>
  
  <p>Users need the ability to explicitly select which property and which matching method when searching, e.g. a user will explicitly search for all matches of process number that equals '132'.</p>
  
  <p>My first approach was to use dynamic linq to construct a Where clause from the search criteria (<a href="https://stackoverflow.com/questions/7200245/dynamic-where-clause-lambdas-in-c">see my original question</a>).  However I'm starting to think that this isn't the best way to do it.</p>
  
  <p>I'm also hoping for a solution that doesn't require me to hard code the result for each property + matching criteria combination.</p>
  
  <p>Any suggestions on how I should implement this search?  It doesn't have to be using my current search form, totally open to any other ideas that fit the requirements.</p>