Page 1 of 1

CROSS APPLY causing error

Posted: Mon 22 Feb 2016 12:35
by peterharris
I'm not sure if this is a LinqConnect issue or dotConnet for PostgreSQL, but this error is caused while using LinqConnect with PostgreSQL. It seems to be generating SQL that utilizes "CROSS APPLY" syntax which doesn't exist in PostgreSQL. Here are steps that can be taken to reproduce the error:

Given the following example database structure:

Code: Select all

Tree    1 -> *    Branch
Branch  1 -> *    Leaf
Leaf    1 -> 0-1  LeafFallDetails
This following LINQ query should produce the SQL syntax error by trying to use "CROSS APPLY" in PostgreSQL. I've not tested if the error still occurs if you don't project a set of entities to a new anonymous object while querying a nested set of entities, I'd imagine that it would, but I have only tested the following scenario:

Code: Select all

dim result = context.Trees.Select(Function(t) New With {
    .Tree = t,
    .FallenLeaves = t.Branches.SelectMany(
        Function(b) b.Leaves.Where(
            Function(l) l.LeafFallDetails IsNot Nothing
        )
    )
}).ToList()

As a side note, sometimes I also seem to get a weird error when projecting to an anonymous type like in the above where I get an exception of something like:

Code: Select all

Unable to cast object of type 'CacheStorageReader[VB$AnonymousType_0`2[Data.Entities.Tree,System.Collections.Generic.IEnumerable`1[Data.Entities.Leaf]]]' to type 'Devart.Data.PostgreSql.PgSqlDataReader'.
When using the following query with the example database structure:

Code: Select all

dim result = context.Trees.Select(Function(t) New With {
    .Tree = t,
    .Leaves = t.Branches.SelectMany(
        Function(b) b.Leaves
    )
}).ToList()
If this should be in the LinqConnect forum, then I can repost there instead if that helps.
Many thanks for your help,

Peter

Re: CROSS APPLY causing error

Posted: Tue 23 Feb 2016 09:46
by MariiaI
Thank you for the report on this. We have reproduced this issue. We will investigate it more clearly and inform you about the results as soon as possible.

Re: CROSS APPLY causing error

Posted: Wed 02 Mar 2016 09:29
by peterharris
It's been a over a week and I was wondering if there has been any updates regarding this issue?

Many thanks,

Peter

Re: CROSS APPLY causing error

Posted: Wed 02 Mar 2016 10:47
by MariiaI
The investigation is in progress. We will definitely inform you about the results as soon as any are available.

Re: CROSS APPLY causing error

Posted: Wed 31 Jan 2018 12:30
by peterharris
It's been almost two years. Is there any more info on this?

Re: CROSS APPLY causing error

Posted: Tue 13 Feb 2018 19:49
by Shalex
1. The generation of CROSS JOIN LATERAL and LEFT JOIN LATERAL when connecting to PostgreSQL Server 9.3 or higher is supported. The functionality will be included in the next public build.
peterharris wrote:Unable to cast object of type 'CacheStorageReader[VB$AnonymousType_0`2[Data.Entities.Tree,System.Collections.Generic.IEnumerable`1[Data.Entities.Leaf]]]' to type 'Devart.Data.PostgreSql.PgSqlDataReader'.
2. We cannot reproduce the error. Please upload a test project with the corresponding DDL/DML script for reproducing to ftp://ftp.devart.com (credentials: anonymous / yourEmail).

Re: CROSS APPLY causing error

Posted: Thu 15 Feb 2018 17:51
by Shalex
New build of dotConnect for PostgreSQL 7.10.1086 is available for download now: viewtopic.php?f=3&t=36600.

Re: CROSS APPLY causing error

Posted: Wed 21 Feb 2018 09:59
by peterharris
Thank you for your reply.

Interestingly, you were able to reproduce the error 2 years ago, which makes me think that the error is now resolved in the latest build.
I will download the latest and try with the original project to see if it produces the same error again, and if it doesn't then I'd say this is resolved. If the error still persists then I will reply here and try to put an example project together.

Many thanks,

Peter