Dynamic variable to call appropriate class property inside LINQ
<p>Is there a way to combine both methods below into one dynamic method, that calls the appropriate Property inside LINQ where clause based on the user input?
I thought about doing something like </p>

<pre><code>var prop = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(name.ToLower()));
</code></pre>

<p>then do something like this in inside LINQ <code>x =&gt; x.{prop} == name</code> <em>not sure if such syntax exist</em></p>

<pre><code>public void FilterByName(string name)
{
    var data = new InfoCollection().Data;
    var result = data.Where(x =&gt; x.State == name)        
    Console.WriteLine(result);
}

public void FilterByCar(string car)
{
    var data = new InfoCollection().Data;
    var result = data.Where(x=&gt; x.Car == car) 
    Console.WriteLine(result);
}

switch(searchByString)
{
    case "name":
    FilterByName(name)
    break;

    case "car":
    FilterByCar(car)
    break;

    defualt:
    break;
}
</code></pre>