I’m using LINQ to SQL for a .NET MVC app.
In my db i have a bunch of columns that have “Y” or “N” values in them.
I’m trying to write a general purpose method that will return all the records in the db where columnName == 'Y'
So far i’ve got this
public IQueryable<Approved> ReturnRecordsByObjectiveFlag(string columnName)
{
return from approved in db.Approved
where approved.GetType().GetProperties().Where(x => x.Name.Equals(columnName)).Equals("Y")
select approved;
}
But that gives me this error
Member access ‘System.String Name’ of ‘System.Reflection.MemberInfo’ not legal on type ‘System.Reflection.PropertyInfo[].
Any idea where i may be going wrong?
Thank you.
Edit; if the properties are actually
char?, i.e.'Y'not"Y", then:(this now copes with all of
string,charandchar?