xyz} whatever xyz becomes. The result of no field at all is what is of
On Jan 11, 7:30 pm, Robert Stam <
rob...@10gen.com> wrote:
> It's a result of BsonDocument functional construction treating C# nulls the
> same way as XDocument does (in other words, C# nulls are ignored).
>
> The way to search for a BSON null is to use the BsonNull.Value constant:
>
> Query.EQ("fieldname", BsonNull.Value);
>
>
>
>
>
>
>
> On Wed, Jan 11, 2012 at 6:29 PM, nuha <
nuri.halpe...@gmail.com> wrote:
> > In C#, when using Query.EQ(string, object), the following was observed:
> > When null is passed as a value, the builder creates a null query {}. (less
> > than expected)
> > When and empty string is passed, the builder creates a query with rvalue
> > of empty string. (expected)
>
> > The danger is that unless well guarded, this can produce a query matching
> > unintended records. Bad for security, bad for updates..
>
> > Is this a documented behavior?
> > The more explicity Query.EQ("foo": new BsonString(null)) would throw, but
> > to the uninitiated all of this is very un-intuitive.
>
> > -------------------------
> > [TestMethod]
> > public void MongoDbQuery_EqWithNullString_ConstructsNullQuery()
> > {
> > string id = null;
> > var query = Query.EQ("OwnerId", id);