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

LINQ queries don't work with enums smaller than int (32 bits)

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Minor - P4 Minor - P4
    • 2.1
    • 1.9.1
    • Linq, Serialization
    • None
    • .Net

    Description

      Reproduce steps:

          // Query
          hamsters.AsQueryable().OfType<Hamster>().Where(hamster => hamster.Color == Color.White).ToList();
          
          // Types
          public class Hamster
          {
              public ObjectId Id { get; private set; }
              public Color Color { get; private set; }
       
              public Hamster(Color color)
              {
                  Color = color;
                  Id = ObjectId.GenerateNewId();
              }
          }
       
          public enum Color : ushort
          {
              Black = 0,
              White = 1,
          }
       
       

      Error:

      Unsupported where clause: ((Int32)hamster.Color == 1).

      Attachments

        Activity

          People

            robert@mongodb.com Robert Stam
            I3arnon Bar Arnon
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: