When a non-nullable enum field is compared to a nullable value the filter does not render correctly.
To reproduce use these types:
public enum E { A, B } public class C { public int Id { get; set; } [BsonRepresentation(BsonType.String)] public E E { get; set; } }
And this code:
var builder = Builders<C>.Filter; var value = (E?)E.A; var filter = builder.Where(x => x.E == value); var registry = BsonSerializer.SerializerRegistry; var serializer = registry.GetSerializer<C>(); var rendered = filter.Render(serializer, registry).ToJson();
The filter renders as:
"{ \"E\" : 0 }"
but should have rendered as:
"{ \"E\" : \"A\" }"
because the underlying field serializer uses String representation.
- is duplicated by
-
CSHARP-1932 Issue with nullable parameter
- Closed
- related to
-
CSHARP-1885 Don't cast nullable types (int?, sbyte?, uint? ..)
- Closed