I have a generic method where I want to specify the IQueryable to retrieve from, the field to use as an ID, and the name of the field to return.
But I get the error:
Method '' has no supported translation to SQL.
How can properly specify the valueExpression below so that it knows how to convert the expression to SQL? What am I doing wrong here?
public void RunTest()
{
Test<DocumentType>(ctx.Query<DocumentType>(), x => x.DocTypeID, x => x.DocType);
}
public void Test<TTable>(IQueryable<TTable> table, Func<TTable, int> idFunc, Expression<Func<TTable, string>> nameExpr)
{
var intVal = 1;
Expression<Func<TTable, bool>> valueExpression = item => idFunc(item) == intVal;
//errors on the Where() here.
var dbName = table.Where(valueExpression).Select(nameExpr).SingleOrDefault();
//make assertions
}
Note: the intVal will be changing in a loop in the Test<>() method. I simplified it here for the question.

And the question is where does that "Param_0" come from. This is where the second wrapping comes into play:
