17
17
using System . Collections . Generic ;
18
18
using System . Linq ;
19
19
using System . Text ;
20
- using System . Text . RegularExpressions ;
21
20
22
21
using MongoDB . Bson ;
23
22
@@ -353,6 +352,11 @@ public static IMongoQuery Near(string name, double x, double y, double maxDistan
353
352
/// <returns>An IMongoQuery.</returns>
354
353
public static IMongoQuery Not ( IMongoQuery query )
355
354
{
355
+ if ( query == null )
356
+ {
357
+ throw new ArgumentNullException ( "query" ) ;
358
+ }
359
+
356
360
var queryDocument = query . ToBsonDocument ( ) ;
357
361
if ( queryDocument . ElementCount == 1 )
358
362
{
@@ -428,6 +432,15 @@ public static IMongoQuery Not(IMongoQuery query)
428
432
/// <returns>An IMongoQuery.</returns>
429
433
public static IMongoQuery NE ( string name , BsonValue value )
430
434
{
435
+ if ( name == null )
436
+ {
437
+ throw new ArgumentNullException ( "name" ) ;
438
+ }
439
+ if ( value == null )
440
+ {
441
+ throw new ArgumentNullException ( "value" ) ;
442
+ }
443
+
431
444
return new QueryDocument ( name , new BsonDocument ( "$ne" , value ) ) ;
432
445
}
433
446
@@ -438,6 +451,11 @@ public static IMongoQuery NE(string name, BsonValue value)
438
451
/// <returns>An IMongoQuery.</returns>
439
452
public static IMongoQuery NotExists ( string name )
440
453
{
454
+ if ( name == null )
455
+ {
456
+ throw new ArgumentNullException ( "name" ) ;
457
+ }
458
+
441
459
return new QueryDocument ( name , new BsonDocument ( "$exists" , false ) ) ;
442
460
}
443
461
@@ -449,6 +467,15 @@ public static IMongoQuery NotExists(string name)
449
467
/// <returns>An IMongoQuery.</returns>
450
468
public static IMongoQuery NotIn ( string name , IEnumerable < BsonValue > values )
451
469
{
470
+ if ( name == null )
471
+ {
472
+ throw new ArgumentNullException ( "name" ) ;
473
+ }
474
+ if ( values == null )
475
+ {
476
+ throw new ArgumentNullException ( "values" ) ;
477
+ }
478
+
452
479
return new QueryDocument ( name , new BsonDocument ( "$nin" , new BsonArray ( values ) ) ) ;
453
480
}
454
481
0 commit comments