Expression yields no result, but there is data

2

This is my query in direct sql.

select c.de_cnpj, c.DT_TransacaoV from T_CRM_StatusPDV c
join T_PDV p on c.DE_CNPJ = p.CNPJ
where DATEDIFF(DAY,c.DT_TransacaoV,GETDATE()) > 45

This is my lambda expression, which in my view corresponds to this query.

var resultado = db.T_CRM_StatusPDV
                  .Join(db.T_PDV, t1 => t1.DE_Cnpj, t2 => t2.CNPJ, (t1, t2) => new { t1, t2})
                  .Where(dt => DbFunctions.DiffDays(dt.t1.DT_TransacaoV, DateTime.Now) > 45
                               && dt.t2.DataCadastro >= dataInicio
                               && dt.t1.DT_ControleV >= dataControle)
                  .Select(i => new { i.t1.DE_Cnpj }).ToList();

It happens that the query brings me more than 100 records, and with lambda, Count brings zero.

    
asked by anonymous 06.06.2014 / 22:13

2 answers

0

I discovered the error. Lack of attention is fda. There is a & such and such, that this relationship is killing. Post solved. Missed more observation from me. This has to rise today and the pressure sometimes makes us not look at the obvious.

    
06.06.2014 / 22:16
2

solution:

var lambda = db.T_CRM_StatusPDV
          .Join(db.T_PDV, t1 => t1.DE_Cnpj, t2 => t2.CNPJ, (t1, t2) => new { t1, t2})
          .Where(dt => DbFunctions.DiffDays(dt.t1.DT_TransacaoV, DateTime.Now) > 45
                    & dt.t2.DataCadastro >= dataInicio
                    & dt.t1.DT_ControleV >= dataControle)
          .Select(i => new { i.t1.DE_Cnpj }).ToList();
    
09.06.2014 / 16:51