I made this LINQ. In the concatenation between DDD and phone number, which I call phone1, it is flicking.
var agendamento = (
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()
from usuariopdv in db.T_UsuarioPDV.Where(usu => usu.IDPDV == pdv.IDPdv)
from usuario in db.T_Usuario.Where(us => us.IDUsuario == usuariopdv.IDUsuario)
where pdv.CNPJ == _agendamento.Cnpj //&& parceiro.NumOs == _agendamento.Os
orderby parceiro.DataVisita descending
select new
{
pdv.CNPJ,
pdv.DataCadastro,
cliente.RazaoSocial,
acao.Acao,
proxima.ProximaAcao,
parceiro.IDOsParceiro,
parceiro.NumOs,
parceiro.DataVisita,
parceiro.DataAgendamento,
parceiro.Tecnico,
usuario.Nome,
telefone1 = "(" + usuario.DDD + ")" + usuario.Telefone
})
.ToList()
.FirstOrDefault();
The error you are giving is the following:
Unable to cast the type 'System.Nullable'1' to type 'System.Object'. LINQ to Entities only supports casting EDM primitive or enumeration types.