What's falser than being false?

Dead Wrong!


When using mongodb in C#, using the IQueryable While function can produce some pretty unusual results.

We had the following code:

app.AsQueryable().Where(x => request.Name == null || x.Name == request.Name);

We were test driving this, so the first test that we had written passed in a request with a null name and expected everything from the db to come back.

We got nothing back.

We replaced request.Name == null with True, but that didn't change anything.

This means that:

True || something

Was being evaluated as equaling False.

For those who don't remember Boolean logic, True || anything is always True.

In the end we found out that the MongoDB IQueryable was not able to handle ORs correctly (That is, at all).

Anyway, I thought that I would post about it to prevent others from banging their heads against the problem for too long.

Comments

Popular posts from this blog

The start of morels - 2018

The End of Summer

Tapely, and much more.