I have this Linq :
var resultado =
(
from pdv in db.T_PDV
from tarefa in db.T_TarefaParceiro.Where(trf => trf.CNPJ == pdv.CNPJ).DefaultIfEmpty()
from parceiro in db.T_OsParceiro.Where(prf => prf.IDTarefaParceiro == tarefa.IDTarefaParceiro)
from acao in db.T_Acao.Where(ac => ac.IDAcao == tarefa.IDAcao).DefaultIfEmpty()
from proxima in db.T_ProximaAcao.Where(pxm => pxm.IDAcao == acao.IDAcao).DefaultIfEmpty()
from info in db.T_InfoClientePdv.Where(inf => inf.CNPJ == pdv.CNPJ).DefaultIfEmpty()
from cliente in db.T_Cliente.Where(clie => clie.IDCliente == info.IDCliente).DefaultIfEmpty()
where pdv.CNPJ == "07599639000184"
select new
{
pdv.CNPJ,
pdv.DataCadastro,
cliente.NomeFantasia,
acao.Acao,
proxima.ProximaAcao,
parceiro.NumOs,
parceiro.DataVisita,
parceiro.DataAgendamento
})
.ToList()
.FirstOrDefault();
As I do in this linq, bring the result to a greater date. There is a field called DataVisita
and it is for this field that I should make a Max
, how do I do it?