Hello,
I would like to control how linq querries my database programaticaly. For instance, I'd like to querry the column X, column Y, or column Z, depending on some conditions.
First of all, I've created an array of all the properties inside my class called myPropertyInfo.
Type MyType = (typeOf(MyClass));
PropertyInfo[] myPropertyInfo = myType.GetProperties(
BindingFlags.Public|BindingFlags.Instance);
the myPropertyInfo array allows me to access each property details (Name, propertyType, etc) through the index*[i]*
Now, how can I use the above information to control how linq querries my DB?
Here's a sample of a querry I'd like to exploit.
var myVar = from tp in db.MyClass
select tp.{expression};
Expression using myPropertyInfo[i] to choose which property(column) to querry.
I'm not sure if that's the way of doing it, but if there's another way to do so, I'll be glad to learn.
Thanks for helping.