@@ -684,6 +684,27 @@ public static IMongoQuery Type(string name, BsonType type)
684
684
return new QueryDocument ( name , condition ) ;
685
685
}
686
686
687
+ /// <summary>
688
+ /// Tests that the type of the named element is equal to some type (see $type).
689
+ /// </summary>
690
+ /// <param name="name">The name of the element to test.</param>
691
+ /// <param name="type">The type to compare to.</param>
692
+ /// <returns>An IMongoQuery.</returns>
693
+ public static IMongoQuery Type ( string name , string type )
694
+ {
695
+ if ( name == null )
696
+ {
697
+ throw new ArgumentNullException ( "name" ) ;
698
+ }
699
+ if ( type == null )
700
+ {
701
+ throw new ArgumentNullException ( "type" ) ;
702
+ }
703
+
704
+ var condition = new BsonDocument ( "$type" , type ) ;
705
+ return new QueryDocument ( name , condition ) ;
706
+ }
707
+
687
708
/// <summary>
688
709
/// Tests that a JavaScript expression is true (see $where).
689
710
/// </summary>
@@ -1448,6 +1469,18 @@ public static IMongoQuery Type<TMember>(Expression<Func<TDocument, TMember>> mem
1448
1469
return new QueryBuilder < TDocument > ( ) . Type ( memberExpression , type ) ;
1449
1470
}
1450
1471
1472
+ /// <summary>
1473
+ /// Tests that the type of the named element is equal to some type (see $type).
1474
+ /// </summary>
1475
+ /// <typeparam name="TMember">The member type.</typeparam>
1476
+ /// <param name="memberExpression">The member expression representing the element to test.</param>
1477
+ /// <param name="type">The type to compare to.</param>
1478
+ /// <returns>An IMongoQuery.</returns>
1479
+ public static IMongoQuery Type < TMember > ( Expression < Func < TDocument , TMember > > memberExpression , string type )
1480
+ {
1481
+ return new QueryBuilder < TDocument > ( ) . Type ( memberExpression , type ) ;
1482
+ }
1483
+
1451
1484
/// <summary>
1452
1485
/// Tests that any of the values in the named array element is equal to some type (see $type).
1453
1486
/// </summary>
@@ -1460,6 +1493,18 @@ public static IMongoQuery Type<TValue>(Expression<Func<TDocument, IEnumerable<TV
1460
1493
return new QueryBuilder < TDocument > ( ) . Type ( memberExpression , type ) ;
1461
1494
}
1462
1495
1496
+ /// <summary>
1497
+ /// Tests that any of the values in the named array element is equal to some type (see $type).
1498
+ /// </summary>
1499
+ /// <typeparam name="TValue">The type of the value.</typeparam>
1500
+ /// <param name="memberExpression">The member expression representing the element to test.</param>
1501
+ /// <param name="type">The type to compare to.</param>
1502
+ /// <returns>An IMongoQuery.</returns>
1503
+ public static IMongoQuery Type < TValue > ( Expression < Func < TDocument , IEnumerable < TValue > > > memberExpression , string type )
1504
+ {
1505
+ return new QueryBuilder < TDocument > ( ) . Type ( memberExpression , type ) ;
1506
+ }
1507
+
1463
1508
/// <summary>
1464
1509
/// Builds a query from an expression.
1465
1510
/// </summary>
@@ -2301,6 +2346,24 @@ public IMongoQuery Type<TMember>(Expression<Func<TDocument, TMember>> memberExpr
2301
2346
return Query . Type ( serializationInfo . ElementName , type ) ;
2302
2347
}
2303
2348
2349
+ /// <summary>
2350
+ /// Tests that the type of the named element is equal to some type (see $type).
2351
+ /// </summary>
2352
+ /// <typeparam name="TMember">The member type.</typeparam>
2353
+ /// <param name="memberExpression">The member expression representing the element to test.</param>
2354
+ /// <param name="type">The type to compare to.</param>
2355
+ /// <returns>An IMongoQuery.</returns>
2356
+ public IMongoQuery Type < TMember > ( Expression < Func < TDocument , TMember > > memberExpression , string type )
2357
+ {
2358
+ if ( memberExpression == null )
2359
+ {
2360
+ throw new ArgumentNullException ( "memberExpression" ) ;
2361
+ }
2362
+
2363
+ var serializationInfo = _serializationInfoHelper . GetSerializationInfo ( memberExpression ) ;
2364
+ return Query . Type ( serializationInfo . ElementName , type ) ;
2365
+ }
2366
+
2304
2367
/// <summary>
2305
2368
/// Tests that any of the values in the named array element is equal to some type (see $type).
2306
2369
/// </summary>
@@ -2319,6 +2382,24 @@ public IMongoQuery Type<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>>
2319
2382
return Query . Type ( serializationInfo . ElementName , type ) ;
2320
2383
}
2321
2384
2385
+ /// <summary>
2386
+ /// Tests that any of the values in the named array element is equal to some type (see $type).
2387
+ /// </summary>
2388
+ /// <typeparam name="TValue">The type of the value.</typeparam>
2389
+ /// <param name="memberExpression">The member expression representing the element to test.</param>
2390
+ /// <param name="type">The type to compare to.</param>
2391
+ /// <returns>An IMongoQuery.</returns>
2392
+ public IMongoQuery Type < TValue > ( Expression < Func < TDocument , IEnumerable < TValue > > > memberExpression , string type )
2393
+ {
2394
+ if ( memberExpression == null )
2395
+ {
2396
+ throw new ArgumentNullException ( "memberExpression" ) ;
2397
+ }
2398
+
2399
+ var serializationInfo = _serializationInfoHelper . GetSerializationInfo ( memberExpression ) ;
2400
+ return Query . Type ( serializationInfo . ElementName , type ) ;
2401
+ }
2402
+
2322
2403
/// <summary>
2323
2404
/// Builds a query from an expression.
2324
2405
/// </summary>
0 commit comments