fluent-mongo
fluent-mongo copied to clipboard
! operator(not) issue
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? :)
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.