views:

93

answers:

1

Hi,

For the life of me, I can't figure out what the problem is with this:

tempData= from a in dx.SomeTable select a;

string searchField="ItemName";
string searchString="BoxPkg";

object[] parameters=new object[]{searchField,searchString};
tempData = tempData.Where("@0 like @1", parameters);

I get this error " {"Expression of type 'Boolean' expected"} "

+1  A: 

I don't think you're able to specify the property name (ItemName) as a parameter (@0). Try this instead:

tempData= from a in dx.SomeTable select a;

string searchField="ItemName";
string searchString="BoxPkg";

object[] parameters=new object[]{searchString};
tempData = tempData.Where(searchField + " like @0", parameters);
AakashM
@AakashNopes. Still the same error mate :|
Sandeep