I Have the following Method:
public List<REP_MEDIDORDISPLAY> GetAllMedidoresDisplay()
{
return ent.TB_MEDIDOR.Select(x => new REP_MEDIDORDISPLAY
{
Data_TOI = x.Data_TOI,
Elemento = x.Elemento,
Fase = x.Fase,
KdKe = x.KD_KE,
N_Equipamento = x.Numero,
Tensao = x.Tensao,
Status = x.TB_REVISAO.Count > 0 ? "Revisão":
x.TB_CHECAGEM_INTERNA.Count > 0 ? "Checagem interna":
x.TB_MESACALIBRACAO.Count > 0 ? "Mesa de calibração":
x.TB_HIPOT.Count > 0 ? "Hipot":
x.TB_INSPECAO.Count > 0? "Inspeção" :
x.TB_AGENDAMENTO.FirstOrDefault(y => y.ID_Medidor == x.ID).Data_Agendamento.HasValue ?
--> Error here (x.TB_AGENDAMENTO.FirstOrDefault(y => y.ID_Medidor == x.ID).Data_Agendamento.Value.ToString()) :String.Empty
}).ToList<REP_MEDIDORDISPLAY>();
}
But it's firing the following error when I try to convert a DateTime to String:
LINQ to Entities does not recognize the method 'System.String ToString()' method, and this method cannot be translated into a store expression.
I hope you can help me guys, I need that value as string, I can't change that to datetime.
Data_Agendamento.Years + Data_Agendamento. Months + ....