[CSHARP-989] LINQ queries don't work with enums smaller than int (32 bits) Created: 08/Jun/14  Updated: 22/Oct/16  Resolved: 22/Oct/16

Status: Closed
Project: C# Driver
Component/s: Linq, Serialization
Affects Version/s: 1.9.1
Fix Version/s: 2.1

Type: Bug Priority: Minor - P4
Reporter: Bar Arnon Assignee: Robert Stam
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

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



 Comments   
Comment by Robert Stam [ 22/Oct/16 ]

This issue has been fixed in the 2.1.0 version of the driver.

Generated at Wed Feb 07 21:38:22 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.