[CSHARP-926] LINQ queries don't work with fields/properties of type byte enum Created: 08/Mar/14  Updated: 22/Apr/15  Resolved: 22/Apr/15

Status: Closed
Project: C# Driver
Component/s: Linq
Affects Version/s: 1.9
Fix Version/s: 2.1

Type: Bug Priority: Major - P3
Reporter: zephuros Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Epic Link: Rewrite Linq

 Description   

To reproduce:

enum Enum1:byte
{
E1,
E2
}
public class C
{
public int _id;
public Enum1 e;
}

var query =
from x in collection.AsQueryable<C>()
where x.e == Enum1.E1
select x;
which results in the following exception:
1
Unsupported where clause: ((Int32)x.e == 0)



 Comments   
Comment by Craig Wilson [ 22/Apr/15 ]

This has been fixed with CSHARP-601

Comment by Ludmila Shako [X] [ 21/Mar/14 ]

I've added a pull request here with a unit test: https://github.com/mongodb/mongo-csharp-driver/pull/179

Comment by zephuros [ 17/Mar/14 ]

I deleted the comment before after test carefully ,
When using 1.9.0-rc0, it still throw exception "Unsupported where clause: ((Int32)x.e == 0)".
But it worked when use a inner object like:
class B

{C c;}

collection.AsQueryable<B>().Where(b => b.c.e == Enum1.E1).ToList()

Comment by Craig Wilson [ 11/Mar/14 ]

Hi zephuros, thanks for the report.

I noticed you put Affects Version 1.9. Are you using 1.9.0-rc0 and came across this, or did you mean a different version? I only ask because I believe this would have been fixed with CSHARP-613 and CSHARP-900.

Thanks,
Craig

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