Method 'System.Object DynamicInvoke(System.Object[])' has nosupported translation to SQL.

S

Steve Richter

getting this error:
Method 'System.Object DynamicInvoke(System.Object[])' has no supported
translation to SQL.

when IQueryable is called and the Where method of Linq.Table is passed
a multi line Func expression:

private pcarDataContext db = new pcarDataContext();

public IQueryable<AccountMasterRow> FindAccountMasterRows(
string InLikeName)
{
string s1 = InLikeName.ToLower();
Func<AccountMasterRow,bool> func = r =>
{
int rv = r.FullName.ToLower().IndexOf(s1);

if (rv >= 0)
return true;
else
return false;
};

return db.AccountMasterRows.Where(
r => func(r)
);

I also get a similar error when passing in a lambda to the Where
method:

The member 'pcar.Models.AccountMasterRow.FullName' has no supported
translation to SQL.

return db.AccountMasterRows.Where(r => r.FullName.ToLower
().IndexOf(s1) >= 0);

In this case, FullName is a public property in the AccountMasterRow
class.

asking for an explanation of this error message.

thanks,

-Steve
 
S

Steve Richter

ok, I got past the 2nd error which said my class property had no
supported translation to SQL. I used one of the properties generated
by Linq to SQL.

but the 1st error remains. When I pass the Func expression ( or
whatever it is called ) to the Where method.

Method 'System.Object DynamicInvoke(System.Object[])' has no supported
translation to SQL.

This reminds me of the C++ template error message days, where I just
dont have the IQ needed to decipher what the error means.

thanks,
 
S

Steve Richter

ok, I got past the 2nd error which said my class property had no
supported translation to SQL. I used one of the properties generated
by Linq to SQL.

but the 1st error remains. When I pass the Func expression ( or
whatever it is called ) to the Where method.

Method 'System.Object DynamicInvoke(System.Object[])' has no supported
translation to SQL.

This reminds me of the C++ template error message days, where I just
dont have the IQ needed to decipher what the error means.

thanks,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top