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

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Minor - P4
    • 2.1
    • Affects Version/s: 1.9.1
    • Component/s: LINQ, Serialization
    • None
    • Environment:
      .Net
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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).
      

            Assignee:
            Robert Stam
            Reporter:
            Bar Arnon
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: