Query using Entityframework why the performance variation?

Asked

Viewed 95 times

2

I have the following querys using Linq to Object:

_Context.GerenciaTransacao.Where(x => x.Placa == "LUN1320").ToList();

in this query, the results return in 100ms.

and

string placa = "LUN1320";

_Context.GerenciaTransacao.Where(x => x.Placa == placa).ToList();

already in this, the results take about 3min to arrive. Why this variation so great?

I need to pass the value in parameter form but could not solve.

   SELECT 
"Extent1"."ID_GERENCIA_TRANSACAO" AS "ID_GERENCIA_TRANSACAO", 
"Extent1"."COD_TRANSACAO" AS "COD_TRANSACAO", 
"Extent1"."DSC_TRANSACAO" AS "DSC_TRANSACAO", 
"Extent1"."PARTE_FIXA" AS "PARTE_FIXA", 
"Extent1"."PARTE_VARIAVEL" AS "PARTE_VARIAVEL", 
"Extent1"."RETORNO" AS "RETORNO", 
"Extent1"."NM_USUARIO" AS "NM_USUARIO", 
"Extent1"."HOST_ACESSO" AS "HOST_ACESSO", 
"Extent1"."DT_ALTERACAO" AS "DT_ALTERACAO", 
"Extent1"."PLACA" AS "PLACA", 
"Extent1"."CHASSI" AS "CHASSI"
FROM "DETROWEB"."TPL_GERENCIA_TRANSACAO" "Extent1"
WHERE ('LUN1320' = "Extent1"."PLACA")

Sql generated in the first case.

SELECT 
"Extent1"."ID_GERENCIA_TRANSACAO" AS "ID_GERENCIA_TRANSACAO", 
"Extent1"."COD_TRANSACAO" AS "COD_TRANSACAO", 
"Extent1"."DSC_TRANSACAO" AS "DSC_TRANSACAO", 
"Extent1"."PARTE_FIXA" AS "PARTE_FIXA", 
"Extent1"."PARTE_VARIAVEL" AS "PARTE_VARIAVEL", 
"Extent1"."RETORNO" AS "RETORNO", 
"Extent1"."NM_USUARIO" AS "NM_USUARIO", 
"Extent1"."HOST_ACESSO" AS "HOST_ACESSO", 
"Extent1"."DT_ALTERACAO" AS "DT_ALTERACAO", 
"Extent1"."PLACA" AS "PLACA", 
"Extent1"."CHASSI" AS "CHASSI"
FROM "DETROWEB"."TPL_GERENCIA_TRANSACAO" "Extent1"
WHERE (("Extent1"."PLACA" = :p__linq__0) OR (("Extent1"."PLACA" IS NULL) AND (:p__linq__0 IS NULL)))

Sql generated in the second case.

1 answer

3


The problem was solved by adding on top of the property the attribute:

[Column("PLACA", TypeName = "varchar2")]

thanks to all who cooperated.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.