-
Type: Bug
-
Resolution: Gone away
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.10.2
-
Component/s: Read Operations
-
None
-
Environment:Windows 10 Pro Bld 18363
It seems like the C# driver is unable to work with Nullable Enums when I expose the IQueryable of the Collection to Microsoft's OData libraries. I've tried it with both EnumRepresentationConvention(BSonType.String) as well as BSonType.Int32.
Here is what I'm trying to achieve:
- Create API document using Swagger.
- Generate the controller and models using Swagger Codegen
- Adjust the controller code to support .NET Core 3.1 (Models are left alone).
- Add OData support to Startup.cs and controller ([EnableQuery()] and exposing of IQueryable<MyObject>)
- Try to query using query string "$filter=MyEnumFld eq 'enumvalue'"
The above create an error of "InvalidOperationException. (Convert({Document}
{MyEnumField}Nullable`1) == 2".
Because swagger code gen marks all Enums as nullable (to support PATCHing use-cases I assume), this above error occurs. When I remove the nullable (question mark) from the model, everything works.
I'd really like the models to not be touched so that they can be regenerated from a shared swagger doc at any time in the future.