fluent-mongo icon indicating copy to clipboard operation
fluent-mongo copied to clipboard

! operator(not) issue

Open Osypchuk opened this issue 13 years ago • 1 comments

I discovered interesting issue with ! and bool variables. Following code returns emtry result:

DocumentCollection.AsQueryable().Where(p=> !p.IsObsolete && p.IsPublished);

Such code works fine: DocumentCollection.AsQueryable().Where(p=> (p.IsObsolete == false) && p.IsPublished);

Is it bug or feature? :)

Osypchuk avatar Nov 10 '11 19:11 Osypchuk

It's a feature :). Yeah, this is a known issue and is actually more difficult to solve than you'd think. Your solution to use == false is the correct way around this. A couple of people have actually taken a shot at fixing this and we always get it halfway there and then something about it doesn't work in all cases or breaks something else.

craiggwilson avatar Nov 10 '11 19:11 craiggwilson