Skip to content

Commit f75c1fb

Browse files
authored
CSHARP-4429: Support resultSerializer = null in MongoQueryable.AppendStage (mongodb#972)
1 parent ded3d20 commit f75c1fb

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/MongoDB.Driver/Linq/MongoQueryable.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public static IMongoQueryable<TResult> AppendStage<TSource, TResult>(
8787
GetMethodInfo(AppendStage, source, stage, resultSerializer),
8888
Expression.Convert(source.Expression, typeof(IMongoQueryable<TSource>)),
8989
Expression.Constant(stage),
90-
Expression.Constant(resultSerializer)));
90+
Expression.Constant(resultSerializer, typeof(IBsonSerializer<TSource>))));
9191
}
9292

9393
/// <summary>

tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp4234Tests.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,21 @@
1616
using System.Linq;
1717
using FluentAssertions;
1818
using MongoDB.Bson;
19+
using MongoDB.Bson.TestHelpers.XunitExtensions;
1920
using MongoDB.Driver.Linq;
2021
using Xunit;
2122

2223
namespace MongoDB.Driver.Tests.Linq.Linq3ImplementationTests.Jira
2324
{
2425
public class CSharp4234Tests : Linq3IntegrationTest
2526
{
26-
[Fact]
27-
public void AppendStage_should_work()
27+
[Theory]
28+
[ParameterAttributeData]
29+
public void AppendStage_should_work([Values(false, true)] bool useResultSerializer)
2830
{
2931
var collection = CreateProductsCollection();
3032
var textStage = "{ $match : { $text : { $search : 'apples' } } }";
31-
var resultSerializer = collection.DocumentSerializer;
33+
var resultSerializer = useResultSerializer ? collection.DocumentSerializer : null;
3234

3335
var queryable = collection
3436
.AsQueryable()

0 commit comments

Comments
 (0)