I know that some similar question were wandering around stack overflow however though none of them seem to work the way I want to. Here's the idea what I want to achieve:
// arrays vary depends what's in bigger loop
string[] columnNames = {"id", "name", "surname", "address", "phone"}
// ...
foreach (string columnName in columnNames)
{
if (condition)
{
IQueryable<tableType> query = from x in dbContext where x.(**columnName**).contains(otherVariable) select x;
}
// ...
// Another queries wrapped in if conditions
}
I've tried this with typeof() and Type.GetProperty() which I found here and it seems not be working whatsoever. Another thing is I want this to be as much as possible in standards with current best practices and if I'm looking into wrong direction then where should I point to? I need to get this sort of method reusable for tens of hundreds of views and tables.
cheers,