@@ -220,6 +220,7 @@ internal virtual BulkWriteResult BulkWrite(BulkWriteArgs args)
220
220
maxDocumentSize ,
221
221
maxWireDocumentSize ,
222
222
args . IsOrdered ?? true ,
223
+ args . BypassDocumentValidation ,
223
224
GetBinaryReaderSettings ( ) ,
224
225
args . Requests ,
225
226
writeConcern ,
@@ -655,7 +656,8 @@ public virtual FindAndModifyResult FindAndModify(FindAndModifyArgs args)
655
656
{ "fields" , ( ) => BsonDocumentWrapper . Create ( args . Fields ) , args . Fields != null } , // optional
656
657
{ "upsert" , true , args . Upsert } , // optional
657
658
{ "maxTimeMS" , ( ) => args . MaxTime . Value . TotalMilliseconds , args . MaxTime . HasValue } , // optional
658
- { "writeConcern" , writeConcern , writeConcern != null && serverInstance . Supports ( FeatureId . FindAndModifyWriteConcern ) }
659
+ { "writeConcern" , writeConcern , writeConcern != null && serverInstance . Supports ( FeatureId . FindAndModifyWriteConcern ) } ,
660
+ { "bypassDocumentValidation" , ( ) => args . BypassDocumentValidation . Value , args . BypassDocumentValidation . HasValue && serverInstance . Supports ( FeatureId . BypassDocumentValidation ) }
659
661
} ;
660
662
try
661
663
{
@@ -1603,6 +1605,7 @@ public virtual IEnumerable<WriteConcernResult> InsertBatch(
1603
1605
maxBatchCount ,
1604
1606
maxBatchLength ,
1605
1607
isOrdered ,
1608
+ options . BypassDocumentValidation ,
1606
1609
GetBinaryReaderSettings ( ) ,
1607
1610
requests ,
1608
1611
writeConcern ,
@@ -1703,43 +1706,49 @@ public virtual MapReduceResult MapReduce(MapReduceArgs args)
1703
1706
if ( args . MapFunction == null ) { throw new ArgumentException ( "MapFunction is null." , "args" ) ; }
1704
1707
if ( args . ReduceFunction == null ) { throw new ArgumentException ( "ReduceFunction is null." , "args" ) ; }
1705
1708
1706
- BsonDocument output ;
1707
- if ( args . OutputMode == MapReduceOutputMode . Inline )
1708
- {
1709
- output = new BsonDocument ( "inline" , 1 ) ;
1710
- }
1711
- else
1709
+ using ( var request = _server . RequestStart ( null ) )
1712
1710
{
1713
- if ( args . OutputCollectionName == null ) { throw new ArgumentException ( "OutputCollectionName is null and OutputMode is not Inline." , "args" ) ; }
1714
- var action = MongoUtils . ToCamelCase ( args . OutputMode . ToString ( ) ) ;
1715
- output = new BsonDocument
1711
+ var serverInstance = _server . RequestConnection . ServerInstance ;
1712
+
1713
+ BsonDocument output ;
1714
+ if ( args . OutputMode == MapReduceOutputMode . Inline )
1715
+ {
1716
+ output = new BsonDocument ( "inline" , 1 ) ;
1717
+ }
1718
+ else
1719
+ {
1720
+ if ( args . OutputCollectionName == null ) { throw new ArgumentException ( "OutputCollectionName is null and OutputMode is not Inline." , "args" ) ; }
1721
+ var action = MongoUtils . ToCamelCase ( args . OutputMode . ToString ( ) ) ;
1722
+ output = new BsonDocument
1716
1723
{
1717
1724
{ action , args . OutputCollectionName } ,
1718
1725
{ "db" , args . OutputDatabaseName , args . OutputDatabaseName != null } , // optional
1719
1726
{ "sharded" , ( ) => args . OutputIsSharded . Value , args . OutputIsSharded . HasValue } , // optional
1720
1727
{ "nonAtomic" , ( ) => args . OutputIsNonAtomic . Value , args . OutputIsNonAtomic . HasValue } // optional
1721
1728
} ;
1722
- }
1729
+ }
1723
1730
1724
- var command = new CommandDocument
1725
- {
1726
- { "mapreduce" , _name } , // all lowercase for backwards compatibility
1727
- { "map" , args . MapFunction } ,
1728
- { "reduce" , args . ReduceFunction } ,
1729
- { "out" , output } ,
1730
- { "query" , ( ) => BsonDocumentWrapper . Create ( args . Query ) , args . Query != null } , // optional
1731
- { "sort" , ( ) => BsonDocumentWrapper . Create ( args . SortBy ) , args . SortBy != null } , // optional
1732
- { "limit" , ( ) => args . Limit . Value , args . Limit . HasValue } , // optional
1733
- { "finalize" , args . FinalizeFunction , args . FinalizeFunction != null } , // optional
1734
- { "scope" , ( ) => BsonDocumentWrapper . Create ( args . Scope ) , args . Scope != null } , // optional
1735
- { "jsMode" , ( ) => args . JsMode . Value , args . JsMode . HasValue } , // optional
1736
- { "verbose" , ( ) => args . Verbose . Value , args . Verbose . HasValue } , // optional
1737
- { "maxTimeMS" , ( ) => args . MaxTime . Value . TotalMilliseconds , args . MaxTime . HasValue } // optional
1738
- } ;
1739
- var result = RunCommandAs < MapReduceResult > ( command ) ;
1740
- result . SetInputDatabase ( _database ) ;
1731
+ var command = new CommandDocument
1732
+ {
1733
+ { "mapreduce" , _name } , // all lowercase for backwards compatibility
1734
+ { "map" , args . MapFunction } ,
1735
+ { "reduce" , args . ReduceFunction } ,
1736
+ { "out" , output } ,
1737
+ { "query" , ( ) => BsonDocumentWrapper . Create ( args . Query ) , args . Query != null } , // optional
1738
+ { "sort" , ( ) => BsonDocumentWrapper . Create ( args . SortBy ) , args . SortBy != null } , // optional
1739
+ { "limit" , ( ) => args . Limit . Value , args . Limit . HasValue } , // optional
1740
+ { "finalize" , args . FinalizeFunction , args . FinalizeFunction != null } , // optional
1741
+ { "scope" , ( ) => BsonDocumentWrapper . Create ( args . Scope ) , args . Scope != null } , // optional
1742
+ { "jsMode" , ( ) => args . JsMode . Value , args . JsMode . HasValue } , // optional
1743
+ { "verbose" , ( ) => args . Verbose . Value , args . Verbose . HasValue } , // optional
1744
+ { "maxTimeMS" , ( ) => args . MaxTime . Value . TotalMilliseconds , args . MaxTime . HasValue } , // optional
1745
+ { "bypassDocumentValidation" , ( ) => args . BypassDocumentValidation . Value , args . BypassDocumentValidation . HasValue && serverInstance . Supports ( FeatureId . BypassDocumentValidation ) }
1746
+ } ;
1747
+ var result = RunCommandAs < MapReduceResult > ( command ) ;
1748
+ result . SetInputDatabase ( _database ) ;
1741
1749
1742
- return result ;
1750
+ return result ;
1751
+ }
1743
1752
}
1744
1753
1745
1754
/// <summary>
@@ -2101,6 +2110,7 @@ public virtual WriteConcernResult Update(IMongoQuery query, IMongoUpdate update,
2101
2110
maxBatchCount ,
2102
2111
maxBatchLength ,
2103
2112
isOrdered ,
2113
+ options . BypassDocumentValidation ,
2104
2114
GetBinaryReaderSettings ( ) ,
2105
2115
requests ,
2106
2116
writeConcern ,
@@ -2216,25 +2226,31 @@ internal BsonBinaryWriterSettings GetWriterSettings(MongoConnection connection)
2216
2226
2217
2227
internal AggregateResult RunAggregateCommand ( AggregateArgs args )
2218
2228
{
2219
- BsonDocument cursor = null ;
2220
- if ( args . OutputMode == AggregateOutputMode . Cursor )
2229
+ using ( var request = _server . RequestStart ( null ) )
2221
2230
{
2222
- cursor = new BsonDocument
2231
+ var serverInstance = _server . RequestConnection . ServerInstance ;
2232
+
2233
+ BsonDocument cursor = null ;
2234
+ if ( args . OutputMode == AggregateOutputMode . Cursor )
2235
+ {
2236
+ cursor = new BsonDocument
2223
2237
{
2224
2238
{ "batchSize" , ( ) => args . BatchSize . Value , args . BatchSize . HasValue }
2225
2239
} ;
2226
- }
2240
+ }
2227
2241
2228
- var aggregateCommand = new CommandDocument
2229
- {
2230
- { "aggregate" , _name } ,
2231
- { "pipeline" , new BsonArray ( args . Pipeline . Cast < BsonValue > ( ) ) } ,
2232
- { "cursor" , cursor , cursor != null } , // optional
2233
- { "allowDiskUse" , ( ) => args . AllowDiskUse . Value , args . AllowDiskUse . HasValue } , // optional
2234
- { "maxTimeMS" , ( ) => args . MaxTime . Value . TotalMilliseconds , args . MaxTime . HasValue } // optional
2235
- } ;
2242
+ var aggregateCommand = new CommandDocument
2243
+ {
2244
+ { "aggregate" , _name } ,
2245
+ { "pipeline" , new BsonArray ( args . Pipeline . Cast < BsonValue > ( ) ) } ,
2246
+ { "cursor" , cursor , cursor != null } , // optional
2247
+ { "allowDiskUse" , ( ) => args . AllowDiskUse . Value , args . AllowDiskUse . HasValue } , // optional
2248
+ { "maxTimeMS" , ( ) => args . MaxTime . Value . TotalMilliseconds , args . MaxTime . HasValue } , // optional
2249
+ { "bypassDocumentValidation" , ( ) => args . BypassDocumentValidation . Value , args . BypassDocumentValidation . HasValue && serverInstance . Supports ( FeatureId . BypassDocumentValidation ) }
2250
+ } ;
2236
2251
2237
- return RunCommandAs < AggregateResult > ( aggregateCommand ) ;
2252
+ return RunCommandAs < AggregateResult > ( aggregateCommand ) ;
2253
+ }
2238
2254
}
2239
2255
2240
2256
// private methods
0 commit comments