Query using Entityframework Why performance variation?

2

I have the following querys using Linq to Object:

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

In this query, results return in 100ms.

and

string placa = "LUN1320";

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

Now in this, the results take about 3min to arrive. Why such a variation?

I need to pass the value as a parameter, but I could not resolve it.

   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.

    
asked by anonymous 14.02.2017 / 15:59

1 answer

3

The problem has been solved by adding the following attribute to the property:

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

Thank you to all who collaborated.

    
14.02.2017 / 17:04