Skip to content

Commit

Permalink
merge hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm360 committed Aug 12, 2022
2 parents a083ce3 + 17e5424 commit 6b3ae15
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -318,17 +318,21 @@ public void SetDocumentId(object document, object id)

public bool TryGetMemberSerializationInfo(string memberName, out BsonSerializationInfo serializationInfo)
{
var modelType = configuration.Schemas.Values
serializationInfo = default!;

var classMap = configuration.Schemas.Values
.Select(s => s.ActiveMap.BsonClassMap)
.Where(cm => cm.GetMemberMap(memberName) != null)
.First()
.ClassType;
var serializer = configuration.Schemas[modelType].ActiveBsonClassMapSerializer;
.FirstOrDefault();

if (classMap is null)
return false;

var serializer = configuration.Schemas[classMap.ClassType].ActiveBsonClassMapSerializer;
if (serializer is IBsonDocumentSerializer documentSerializer)
return documentSerializer.TryGetMemberSerializationInfo(memberName, out serializationInfo);
else
throw new InvalidOperationException("Can't find a valid serializer");
return false;
}

// Helpers.
Expand Down

0 comments on commit 6b3ae15

Please sign in to comment.