Skip to content
This repository was archived by the owner on Oct 26, 2025. It is now read-only.
This repository was archived by the owner on Oct 26, 2025. It is now read-only.

Unexpected (incorrect?) results when querying on documents missing fields. #3

@tom1952

Description

@tom1952

If I have a string property, SomeString, that is missing from some documents in a collection, querying on this property is really hard. It's complicated that the querying in the traditional filter/$match semantics doesn't match the semantics of a $expr or $project expression.

This will match on documents missing the SomeString field.

.Select(c => new { IsNull = c.SomeString!= null })
{ "$project" : { "IsNull" : { "$ne" : ["$SomeString", null] }, "_id" : 0 } }

However, this will exclude documents missing that field:

{ "$match" : { "SomeString" : { "$ne" : null } } }
.Where(c => c.SomeString!= null)

This is super frustrating and is not obviously expression in vanilla C#/.Net. The assumption in the .Net/C# querying code is that the field exists since we're querying on a static type (as opposed to, say, an ExpandoObject).

(Moved this issue over from bitbucket)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions