Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-5043

Enum conversion within IQueryable fails with Expression not supported exception

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Critical - P2 Critical - P2
    • 2.28.0
    • Affects Version/s: None
    • Component/s: LINQ3
    • None
    • Fully Compatible
    • Dotnet Drivers
    • Needed
    • Hide
      1. What would you like to communicate to the user about this feature?
        2. Would you like the user to see examples of the syntax and/or executable code and its output?
        3. Which versions of the driver/connector does this apply to?

      Not sure if documentation is needed or not. We're simply supporting a kind of conversion that we previously weren't in LINQ.

      Show
      What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to? Not sure if documentation is needed or not. We're simply supporting a kind of conversion that we previously weren't in LINQ.

      Summary

      My query includes a DTO conversion. As soon as this DTO contains an enum, which should also be converted from a source to a target type, the query fails with the exception ‘`Expression not supported’. We actually use Automapper for the conversion, but during the error analysis we were able to reproduce the behavior with the simplest enum conversion, a cast. The behavior occurs with the LinqProvider.V3, as soon as we switch to the LinqV2 provider, it works.

      It seems to me that the following requests in the community seem to have the same or at least a similar problem:

      https://www.mongodb.com/community/forums/t/conversion-from-nullable-enum-to-enum-fails-with-exception-for-linq3-provider/249557

      https://www.mongodb.com/community/forums/t/c-driver-linq3-convert-enuma-enumb-not-supported/267726

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            tobias.stieglmeier@baramundi.com Tobias Stieglmeier
            Votes:
            4 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: