0
Can anyone help me with the following mistake?
Here below is my code. I am trying to fix this error, but I did not succeed.
public IEnumerable<Dia1> GetPendenciasByUser(int centroId)
{
var query = Db.Dia1S
.Join(Db.Cadastros, dia1 => dia1.PatientId, cad => cad.PatientId, (dia1, cad) => new { dia1, cad })
.Join(Db.Randomizacao, dia1 => dia1.dia1.PatientId, rand => rand.PatientId, (dia1, rand) => new { dia1, rand })
.Where(s => s.dia1.dia1.dtd1 == null ? (Convert.ToInt32(DateTime.Now - s.rand.RandomizacaoData)) > 1 : (Convert.ToInt32(Convert.ToDateTime(s.dia1.dia1.dtd1) - s.rand.RandomizacaoData)) > 1 )
.Select(s => s.dia1.dia1)
.ToList();
return query;
}
that is prq the EF does not know how to manipulate functions that are not in its mapping or... yours (Convert.Toint32(Datetime.Now - s.rand.Randomizacaodata)) ... it does not know convert the function Convert.Toint32( for a Quey validate.... you can see some libraries that help do this, or you can try casting using (int? )(Datetime.Now - s.rand.Randomizacaodata)
– Marco Souza
I understood the casting part, but you can give me an example?
– Leonardo Macedo
Maybe in
Functions
until the conversion, the problem and we often do not know what you need. that you did as already said does not work.– novic