1717using System . Collections . Generic ;
1818using System . Linq ;
1919using System . Text ;
20- using System . Text . RegularExpressions ;
2120
2221using MongoDB . Bson ;
2322
@@ -353,6 +352,11 @@ public static IMongoQuery Near(string name, double x, double y, double maxDistan
353352 /// <returns>An IMongoQuery.</returns>
354353 public static IMongoQuery Not ( IMongoQuery query )
355354 {
355+ if ( query == null )
356+ {
357+ throw new ArgumentNullException ( "query" ) ;
358+ }
359+
356360 var queryDocument = query . ToBsonDocument ( ) ;
357361 if ( queryDocument . ElementCount == 1 )
358362 {
@@ -428,6 +432,15 @@ public static IMongoQuery Not(IMongoQuery query)
428432 /// <returns>An IMongoQuery.</returns>
429433 public static IMongoQuery NE ( string name , BsonValue value )
430434 {
435+ if ( name == null )
436+ {
437+ throw new ArgumentNullException ( "name" ) ;
438+ }
439+ if ( value == null )
440+ {
441+ throw new ArgumentNullException ( "value" ) ;
442+ }
443+
431444 return new QueryDocument ( name , new BsonDocument ( "$ne" , value ) ) ;
432445 }
433446
@@ -438,6 +451,11 @@ public static IMongoQuery NE(string name, BsonValue value)
438451 /// <returns>An IMongoQuery.</returns>
439452 public static IMongoQuery NotExists ( string name )
440453 {
454+ if ( name == null )
455+ {
456+ throw new ArgumentNullException ( "name" ) ;
457+ }
458+
441459 return new QueryDocument ( name , new BsonDocument ( "$exists" , false ) ) ;
442460 }
443461
@@ -449,6 +467,15 @@ public static IMongoQuery NotExists(string name)
449467 /// <returns>An IMongoQuery.</returns>
450468 public static IMongoQuery NotIn ( string name , IEnumerable < BsonValue > values )
451469 {
470+ if ( name == null )
471+ {
472+ throw new ArgumentNullException ( "name" ) ;
473+ }
474+ if ( values == null )
475+ {
476+ throw new ArgumentNullException ( "values" ) ;
477+ }
478+
452479 return new QueryDocument ( name , new BsonDocument ( "$nin" , new BsonArray ( values ) ) ) ;
453480 }
454481
0 commit comments