Subject Another incompatible query generation of provider
Author Marco Aurelio Castro
Hi,

Continuing what I've posted in another e-mail, the following code
generates now an OUTER APPLY code that is not interpreted with Firebird.

var r = from cc in ConnModelos.Context().CONTA_CORRENTE
from ie in cc.NOTAS_ENTRADA.ITENS_ENTRADA
where Compras.Where(c => c == cc.OPERACOES.ALTERA_ESTOQUE).Any()
&& cc.DATA_LANCAMENTO >= _from && cc.DATA_LANCAMENTO < _to
&& ie.PRODUTOS.ESTOQUES.Where(w => w.FILIAL ==
Filial).FirstOrDefault().DATA_PRIMEIRA_COMPRA >= _from
&& ie.PRODUTOS.ESTOQUES.Where(w => w.FILIAL ==
Filial).FirstOrDefault().DATA_PRIMEIRA_COMPRA < _to

^ this generated the OUTER APPLY
select new
{
Produto = ie.PRODUTO,
NomeProduto = ie.PRODUTOS.NOME,
MarcaID = ie.PRODUTOS.MARCAS.MARCA,
NomeMarca = ie.PRODUTOS.MARCAS.NOME_MARCA,
QtdComprados = ie.QUANTIDADE
};

Generated

SELECT
"GroupBy1"."A1" AS "C1"
FROM ( SELECT
COUNT("Filter4"."A1") AS "A1"
FROM ( SELECT
1 AS "A1"
FROM ( SELECT
"Project2"."DATA_LANCAMENTO" AS "DATA_LANCAMENTO",
"Project2"."CODOPERACAO" AS "CODOPERACAO",
"Project2"."DATA_PRIMEIRA_COMPRA" AS "DATA_PRIMEIRA_COMPRA",
"Limit2"."DATA_PRIMEIRA_COMPRA" AS "DATA_PRIMEIRA_COMPRA1"
FROM (SELECT
"Extent1"."DATA_LANCAMENTO" AS "DATA_LANCAMENTO",
"Extent1"."CODOPERACAO" AS "CODOPERACAO",
"Extent2"."LIVRO" AS "LIVRO",
"Limit1"."DATA_PRIMEIRA_COMPRA" AS "DATA_PRIMEIRA_COMPRA"
FROM "CONTA_CORRENTE" AS "Extent1"
INNER JOIN "ITENSENTRADA" AS "Extent2" ON "Extent1"."NOTA_ENTRADA" =
"Extent2"."NOTA_ENTRADA"
OUTER APPLY (SELECT FIRST (1)
"Extent3"."DATA_PRIMEIRA_COMPRA" AS "DATA_PRIMEIRA_COMPRA"
FROM "ESTOQUES" AS "Extent3"
WHERE ("Extent2"."LIVRO" = "Extent3"."LIVRO") AND ("Extent3"."FILIAL" =
@p__linq__2) ) AS "Limit1" ) AS "Project2"
OUTER APPLY (SELECT FIRST (1)
"Extent4"."DATA_PRIMEIRA_COMPRA" AS "DATA_PRIMEIRA_COMPRA"
FROM "ESTOQUES" AS "Extent4"
WHERE ("Project2"."LIVRO" = "Extent4"."LIVRO") AND ("Extent4"."FILIAL" =
@p__linq__4) ) AS "Limit2"
LEFT OUTER JOIN "LIVROS" AS "Extent5" ON "Project2"."LIVRO" =
"Extent5"."LIVRO"
LEFT OUTER JOIN "LIVROS" AS "Extent6" ON "Project2"."LIVRO" =
"Extent6"."LIVRO"
LEFT OUTER JOIN "LIVROS" AS "Extent7" ON "Project2"."LIVRO" =
"Extent7"."LIVRO"
LEFT OUTER JOIN "EDITORAS" AS "Extent8" ON "Extent7"."EDITORA" =
"Extent8"."EDITORA"
) AS "Project4"
WHERE (((( EXISTS (SELECT
1 AS "C1"
FROM (SELECT
"UnionAll2"."C1" AS "C1"
FROM (SELECT
"UnionAll1"."C1" AS "C1"
FROM (SELECT
13 AS "C1"
FROM ( SELECT 1 AS X FROM RDB$DATABASE) AS "SingleRowTable1"
UNION ALL
SELECT
14 AS "C1"
FROM ( SELECT 1 AS X FROM RDB$DATABASE) AS "SingleRowTable2") AS "UnionAll1"
UNION ALL
SELECT
39 AS "C1"
FROM ( SELECT 1 AS X FROM RDB$DATABASE) AS "SingleRowTable3") AS "UnionAll2"
UNION ALL
SELECT
40 AS "C1"
FROM ( SELECT 1 AS X FROM RDB$DATABASE) AS "SingleRowTable4") AS "UnionAll3"
INNER JOIN "OPERACOES" AS "Extent9" ON "UnionAll3"."C1" =
"Extent9"."ALTERAESTOQUE"
WHERE "Project4"."CODOPERACAO" = "Extent9"."CODOPERACAO"
)) AND ("Project4"."DATA_LANCAMENTO" >= @p__linq__0)) AND
("Project4"."DATA_LANCAMENTO" < @p__linq__1)) AND
("Project4"."DATA_PRIMEIRA_COMPRA" >= @p__linq__3)) AND
("Project4"."DATA_PRIMEIRA_COMPRA1" < @p__linq__5)
) AS "Filter4"
) AS "GroupBy1"

--
Thanks,

Marco Aurélio Castro
Diretor
McSoft


[Non-text portions of this message have been removed]