I am using LINQ-to-Entities and here is my query
public void SomeFunction(string searchField)
{
var data = from a in dx.SomeTable where
a.SomeProperty="270"
select a;
.
.
.
}
Now if I had to use the value of the parameter “searchField” as the property to be selected in the where clause then how do I do it ?
i.e I want to assign the value of the parameter “searchField” to the property I am checking in the where clause.
So … the value of “SomeProperty” in a.SomeProperty must be the value of “searchField”. How to do this ?
PS :
I dont want a.SomeProperty=searchField.
What I want is “SomeProperty” itself to be replaced by the value of “searchField” and then , this has to be checked to see if its equal to 270.
Scottgu posted how to do this a while ago:
http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx