1
I did this LINQ. In the concatenation between DDD and phone number, which I call phone 1 is giving dick.
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 what is 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.
pnet what types of DDD and Phone?
– anmaia
int and string, I think that’s it, right? But in a concatenation it doesn’t do the automatic cast?
– pnet
Yeah, the names of the guys are
int
andstring
. Yes, the primitive types to string cast is automatic. No need to.ToString()
in this case. See the correction I made in my reply. It should help you.– anmaia