title: How to filter LINQ query on dynamic columns and dynamic property in C#?
body: <p>I am facing trouble in fetching the filtered records in my LINQ Query to retrieve the columns dynamically based on condition and property also based on condition (ex. Contains, Equals, StartsWith, EndsWith).</p>
  <p>I have a list of records like below -</p>
  <pre><code> List&lt;Employee&gt; employees = new List&lt;Employee&gt;()
              {
  
                  new Employee()
                  {
                      name =&quot;Andy&quot;, cityCriteria=&quot;Florida West&quot;, state   =&quot;NYC&quot;
                  },
                  new Employee()
                  {
                      name = &quot;John&quot;, cityCriteria = &quot;West Virginia&quot;, state = &quot;Arizona&quot;
                  },
                  new Employee()
                  {
                      name = &quot;Nichole&quot;, cityCriteria = &quot;East Florida&quot;, state = &quot;NYC&quot;
                  }
              };
  
  </code></pre>
  <p>So, this is just some sample records the data will be coming from database and it will be so many records.
  Now, what i want to acheive is I have to notify all the persons if any Video posted with the City matching as per the list . So, i can receive NotificationValue as City:Florida:startsWith , City:Florida: Equals , City:Florida:Contains etc and there could be State Criteria too.
  So, how can i filter the records dynamically in the list like if input is Starts with i should use StartsWith ex</p>
  <pre><code>If Input is City:Florida:startsWith --&gt; 
   var result = employees.where(i=&gt;i.CityCriteria.StartsWith(&quot;Florida&quot;).toList();
  
  If Input is City:Florida:Contains --&gt; 
   var result = employees.where(i=&gt;i.CityCriteria.Contains(&quot;Florida&quot;).toList();
  
  If Input is City:Florida:EndsWith --&gt; 
   var result = employees.where(i=&gt;i.CityCriteria.EndsWith(&quot;Florida&quot;).toList();
  
  If Input is City:Florida:Equals --&gt; 
   var result = employees.where(i=&gt;i.CityCriteria.Equals(&quot;Florida&quot;).toList();
  </code></pre>
  <p>I don't want to use multiple conditions and form the Where clause . I want it to be dynamic like if i receive starts with it should replace LINQ query starts , endswith ,equals etc and also it should be flexible with dynamic column like I have to apply same logic for State,Country,Zip etc'</p>
  <p>Please post some sample code if possible</p>