The parameter at position 1 is of an unsupported type: Call

Posts   
 
    
mohamed avatar
mohamed
User
Posts: 136
Joined: 10-Mar-2008
# Posted on: 18-Jul-2010 14:45:56   

This query

var q = from trxd2 in metaData.TransactionsD select new { trxd2.Balance, XX = (trxd2.Balance ?? 0m) < 0m ? Math.Abs(trxd2.Balance ?? 0m) : 0m, }; var result = q.ToList();

throw an exception that ** "The parameter at position 1 is of an unsupported type: Call " **

I tried to call Math.Abs(trxd2.Balance ?? 0m) alone, it works fine

any help ??

using 2.6 Adapter mode for sql file version 2.6.10.517 latest version

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 19-Jul-2010 06:02:19   

Math.Abs isn't mapped. You have to create your own Custom Function Mapping.

David Elizondo | LLBLGen Support Team
mohamed avatar
mohamed
User
Posts: 136
Joined: 10-Mar-2008
# Posted on: 19-Jul-2010 12:43:56   

mohamed wrote:

This query

var q = from trxd2 in metaData.TransactionsD select new { trxd2.Balance, XX = Math.Abs(trxd2.Balance ?? 0m) }; var result = q.ToList();

I tried to call Math.Abs(trxd2.Balance ?? 0m) alone, it works fine

why it didn't work under condition ??

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 19-Jul-2010 15:44:29   

That second query: the Math.Abs() is a call to an in-memory method, and compiled in the projection, the first query: it is embedded in a CASE statement, and therefore requires a mapping.

mohamed avatar
mohamed
User
Posts: 136
Joined: 10-Mar-2008
# Posted on: 19-Jul-2010 16:00:12   

Walaa wrote:

That second query: the Math.Abs() is a call to an in-memory method, and compiled in the projection, the first query: it is embedded in a CASE statement, and therefore requires a mapping.

Thank you Walaa. Could you please Inform me with details how is the linq provider conceder to call in memory or converted to SQL statement.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 19-Jul-2010 16:32:19   

It depends on whether the framework can find a function mapped to this method or not. If not it will be considered an in-memory method.

Default supported methods