File tree Expand file tree Collapse file tree 3 files changed +4
-17
lines changed Expand file tree Collapse file tree 3 files changed +4
-17
lines changed Original file line number Diff line number Diff line change @@ -487,20 +487,7 @@ public override BsonDocument Render(RenderArgs<TDocument> args)
487
487
{
488
488
var renderedField = _field . Render ( args ) ;
489
489
490
- BsonValue value ;
491
- switch ( _direction )
492
- {
493
- case SortDirection . Ascending :
494
- value = 1 ;
495
- break ;
496
- case SortDirection . Descending :
497
- value = - 1 ;
498
- break ;
499
- default :
500
- throw new InvalidOperationException ( "Unknown value for " + typeof ( SortDirection ) + "." ) ;
501
- }
502
-
503
- return new BsonDocument ( renderedField . FieldName , value ) ;
490
+ return new BsonDocument ( renderedField . FieldName , _direction . Render ( ) ) ;
504
491
}
505
492
}
506
493
Original file line number Diff line number Diff line change @@ -295,7 +295,7 @@ public override BsonDocument Render(RenderArgs<TDocument> args)
295
295
{
296
296
var renderedField = _field . Render ( args ) ;
297
297
298
- return new BsonDocument ( renderedField . FieldName , _direction . ToBsonValue ( ) ) ;
298
+ return new BsonDocument ( renderedField . FieldName , _direction . Render ( ) ) ;
299
299
}
300
300
}
301
301
@@ -308,7 +308,7 @@ public ValueDirectionalSortDefinition(SortDirection direction)
308
308
_direction = direction ;
309
309
}
310
310
311
- internal override BsonValue RenderAsBsonValue ( RenderArgs < TDocument > args ) => _direction . ToBsonValue ( ) ;
311
+ internal override BsonValue RenderAsBsonValue ( RenderArgs < TDocument > args ) => _direction . Render ( ) ;
312
312
313
313
public override BsonDocument Render ( RenderArgs < TDocument > args )
314
314
{
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ namespace MongoDB.Driver
20
20
{
21
21
internal static class SortDirectionExtensions
22
22
{
23
- internal static BsonValue ToBsonValue ( this SortDirection direction )
23
+ internal static BsonValue Render ( this SortDirection direction )
24
24
{
25
25
return direction switch
26
26
{
You can’t perform that action at this time.
0 commit comments