private BsonSerializationInfo GetSerializationInfoMember(IBsonSerializer serializer, MemberExpression memberExpression) { var declaringType = memberExpression.Expression.Type; var memberName = memberExpression.Member.Name; var containingExpression = memberExpression.Expression; if (containingExpression.Type == DocumentType) { try { return serializer.GetMemberSerializationInfo(memberName); } catch (NotSupportedException) { var message = string.Format("LINQ queries on fields or properties of class {0} are not supported because the serializer for {0} does not implement the GetMemberSerializationInfo method.", declaringType.Name); throw new NotSupportedException(message); } } else { var containingSerializationInfo = GetSerializationInfo(serializer, containingExpression); try { var memberSerializationInfo = containingSerializationInfo.Serializer.GetMemberSerializationInfo(memberName); return new BsonSerializationInfo( containingSerializationInfo.ElementName + "." + memberSerializationInfo.ElementName, memberSerializationInfo.Serializer, memberSerializationInfo.NominalType, memberSerializationInfo.SerializationOptions); } catch (NotSupportedException) { var message = string.Format("LINQ queries on fields or properties of class {0} are not supported because the serializer for {0} does not implement the GetMemberSerializationInfo method.", declaringType.Name); throw new NotSupportedException(message); } } }