Skip to content

Commit 116b643

Browse files
committed
Work in progress.
1 parent 5e117c1 commit 116b643

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/MongoDB.Driver/Linq/Linq3Implementation/KnownSerializerFinders/KnownSerializerFinderVisitMethodCall.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,18 @@ internal partial class KnownSerializerFinderVisitor
592592
MongoEnumerableMethod.StandardDeviationSampleSingleWithSelector,
593593
];
594594

595+
private static readonly HashSet<MethodInfo> __stringConcatMethods =
596+
[
597+
StringMethod.ConcatWith1Object,
598+
StringMethod.ConcatWith2Objects,
599+
StringMethod.ConcatWith2Strings,
600+
StringMethod.ConcatWith3Objects,
601+
StringMethod.ConcatWith3Strings,
602+
StringMethod.ConcatWith4Strings,
603+
StringMethod.ConcatWithObjectArray,
604+
StringMethod.ConcatWithStringArray
605+
];
606+
595607
private static readonly HashSet<MethodInfo> __stringContainsMethods =
596608
[
597609
StringMethod.ContainsWithChar,
@@ -1307,7 +1319,7 @@ void DeduceAsQueryableMethodSerializers()
13071319

13081320
if (IsNotKnown(node) && IsItemSerializerKnown(sourceExpression, out var sourceItemSerializer))
13091321
{
1310-
var resultSerializer = IQueryableSerializer.Create(sourceItemSerializer);
1322+
var resultSerializer = NestedAsQueryableSerializer.Create(sourceItemSerializer);
13111323
AddKnownSerializer(node, resultSerializer);
13121324
}
13131325
}
@@ -1439,6 +1451,10 @@ void DeduceConcatMethodSerializers()
14391451
DeduceCollectionAndCollectionSerializers(firstExpression, secondExpression);
14401452
DeduceCollectionAndCollectionSerializers(node, firstExpression);
14411453
}
1454+
else if (method.IsOneOf(__stringConcatMethods))
1455+
{
1456+
DeduceReturnsStringSerializer();
1457+
}
14421458
else
14431459
{
14441460
DeduceUnknownMethodSerializer();

src/MongoDB.Driver/Linq/Linq3Implementation/KnownSerializerFinders/KnownSerializerFinderVisitNew.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ protected override Expression VisitNew(NewExpression node)
6868

6969
IBsonSerializer GetKnownSerializer(ConstructorInfo constructor)
7070
{
71-
if (constructor.DeclaringType == typeof(BsonDocument))
71+
if (constructor == null)
72+
{
73+
return null;
74+
}
75+
else if (constructor.DeclaringType == typeof(BsonDocument))
7276
{
7377
return BsonDocumentSerializer.Instance;
7478
}

0 commit comments

Comments
 (0)