Since propValue
is a PropertyInfo
object, you need to use the GetValue
method
foreach (Student stu in formStudents.Where(x => ((string)propValue.GetValue(x, null)) == "John"))
However, from the description of problem, it seems like you might make your life easier by looking into the Dynamic Linq library (also available on NuGet):
using System.Linq.Dynamic;
...
foreach (Student stu in formStudents.Where("StudentName = @0", "John"))