Filter a NULL type in lambda Expression or Line

Asked

Viewed 651 times

0

Hello, my entity To has a long type attribute that can be NULL making relationship with the entity B, by making a filter with a Lambda expression with this attribute to bring all records that are different from NULL he doesn’t recognize my condition WHERE and ends up returning all the objects of the entity. Follow the consultation.

return Context.MatriculaInscricaoAluno.Where(p => p.TituloID != null ).Count();

in syntax SQL Server works as follows.

select * from Siscona.MatriculaInscricaoAluno where TituloID is NULL

thank you all.

  • 1

    the guy should be long? right ? Try to: Where(p => p.TituloID.HasValue)

  • 1

    I think in SQL, it would be is not null

  • Against, unfortunately nothing.

  • Put your as is, a minimum checkable example please

1 answer

0


You can make the direct comparison of your object:

return Context.MatriculaInscricaoAluno.Where(p => p.Titulo == null).ToList().Count();
  • Unfortunately nothing friend.

  • then put: "". Where(p=>p.TituloID.Value == null || p.TituloID.Value == 0)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.