Page 1 of 1

Could not format node 'New' for execution as SQL

Posted: Wed 11 May 2011 08:19
by seser
I got an InvalidOperationException with message "Could not format node 'New' for execution as SQL." at the following query.

var source = db.Users.Where(a => (bool)db.Filter(a, keyword)).ToList();

here "Filter" is a database function that have two parameters and returns boolean.

I'm using linq to postgresql ,
and I expect that generated sql query like "select u.* from userrs u where filter(u, 'hebele')"

Posted: Thu 12 May 2011 10:24
by StanislavK
Please specify the DBMS you are using.

I will send you a test project in a letter, please check that it is not blocked by your mail filter. The projects includes a model created for the PostgreSQL database.

Please describe what should be changed in the sample to reproduce the problem.

Posted: Thu 12 May 2011 13:16
by seser
Thanks for your interest.

I'm using postgresql 9.0.

My function accepts takes record as parameter, not a field value. So, my linq query likes "db.Filter(a, keyword)" not "db.Filter(a.Name, keyword)". this is the main difference.

I don't know, this usage my be silly.
Probably database servers except postgresql does not support this usage.

Posted: Fri 13 May 2011 06:39
by StanislavK
In this case, the problem is that an object of a custom type (i.e., the row type of the 'users' table) actually should be passed as a function argument. Since LinqConnect does not support user-defined types, such an operation is not allowed.

A possible way to resolve the issue is to create (and use in the model) an overload of the 'filter' function that takes parameters of simple types only.