Could not format node 'New' for execution as SQL

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
seser
Posts: 17
Joined: Thu 13 Jan 2011 20:37

Could not format node 'New' for execution as SQL

Post by seser » Wed 11 May 2011 08:19

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')"

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Thu 12 May 2011 10:24

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.

seser
Posts: 17
Joined: Thu 13 Jan 2011 20:37

Post by seser » Thu 12 May 2011 13:16

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.

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Fri 13 May 2011 06:39

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.

Post Reply