@@ -220,6 +220,7 @@ internal virtual BulkWriteResult BulkWrite(BulkWriteArgs args)
220220 maxDocumentSize ,
221221 maxWireDocumentSize ,
222222 args . IsOrdered ?? true ,
223+ args . BypassDocumentValidation ,
223224 GetBinaryReaderSettings ( ) ,
224225 args . Requests ,
225226 writeConcern ,
@@ -655,7 +656,8 @@ public virtual FindAndModifyResult FindAndModify(FindAndModifyArgs args)
655656 { "fields" , ( ) => BsonDocumentWrapper . Create ( args . Fields ) , args . Fields != null } , // optional
656657 { "upsert" , true , args . Upsert } , // optional
657658 { "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 ) }
659661 } ;
660662 try
661663 {
@@ -1603,6 +1605,7 @@ public virtual IEnumerable<WriteConcernResult> InsertBatch(
16031605 maxBatchCount ,
16041606 maxBatchLength ,
16051607 isOrdered ,
1608+ options . BypassDocumentValidation ,
16061609 GetBinaryReaderSettings ( ) ,
16071610 requests ,
16081611 writeConcern ,
@@ -1703,43 +1706,49 @@ public virtual MapReduceResult MapReduce(MapReduceArgs args)
17031706 if ( args . MapFunction == null ) { throw new ArgumentException ( "MapFunction is null." , "args" ) ; }
17041707 if ( args . ReduceFunction == null ) { throw new ArgumentException ( "ReduceFunction is null." , "args" ) ; }
17051708
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 ) )
17121710 {
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
17161723 {
17171724 { action , args . OutputCollectionName } ,
17181725 { "db" , args . OutputDatabaseName , args . OutputDatabaseName != null } , // optional
17191726 { "sharded" , ( ) => args . OutputIsSharded . Value , args . OutputIsSharded . HasValue } , // optional
17201727 { "nonAtomic" , ( ) => args . OutputIsNonAtomic . Value , args . OutputIsNonAtomic . HasValue } // optional
17211728 } ;
1722- }
1729+ }
17231730
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 ) ;
17411749
1742- return result ;
1750+ return result ;
1751+ }
17431752 }
17441753
17451754 /// <summary>
@@ -2101,6 +2110,7 @@ public virtual WriteConcernResult Update(IMongoQuery query, IMongoUpdate update,
21012110 maxBatchCount ,
21022111 maxBatchLength ,
21032112 isOrdered ,
2113+ options . BypassDocumentValidation ,
21042114 GetBinaryReaderSettings ( ) ,
21052115 requests ,
21062116 writeConcern ,
@@ -2216,25 +2226,31 @@ internal BsonBinaryWriterSettings GetWriterSettings(MongoConnection connection)
22162226
22172227 internal AggregateResult RunAggregateCommand ( AggregateArgs args )
22182228 {
2219- BsonDocument cursor = null ;
2220- if ( args . OutputMode == AggregateOutputMode . Cursor )
2229+ using ( var request = _server . RequestStart ( null ) )
22212230 {
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
22232237 {
22242238 { "batchSize" , ( ) => args . BatchSize . Value , args . BatchSize . HasValue }
22252239 } ;
2226- }
2240+ }
22272241
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+ } ;
22362251
2237- return RunCommandAs < AggregateResult > ( aggregateCommand ) ;
2252+ return RunCommandAs < AggregateResult > ( aggregateCommand ) ;
2253+ }
22382254 }
22392255
22402256 // private methods
0 commit comments