[CSHARP-1509] FilterDefinitionBuilder Where can result in an InvalidCastException when filter is rendered Created: 14/Dec/15 Updated: 18/May/16 Resolved: 11/Jan/16 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | Linq |
| Affects Version/s: | 2.2 |
| Fix Version/s: | 2.2.4 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Robert Stam | Assignee: | Craig Wilson |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Description |
|
Given the following class:
the following query will throw an InvalidCastException:
Note: this worked in 2.0.2 but no longer works in 2.1.1+. |
| Comments |
| Comment by Githook User [ 17/Mar/16 ] | |
|
Author: {u'username': u'craiggwilson', u'name': u'Craig Wilson', u'email': u'craiggwilson@gmail.com'}Message: | |
| Comment by Githook User [ 11/Jan/16 ] | |
|
Author: {u'username': u'craiggwilson', u'name': u'Craig Wilson', u'email': u'craiggwilson@gmail.com'}Message: | |
| Comment by Robert Stam [ 14/Dec/15 ] | |
|
Possible workarounds in the meantime: 1. Declare value as an int so that it matches the type of x.Prop The third option looks like this:
Note that the third option might match unexpected documents if casting value to an int requires truncating because the value doesn't fit in 32 bits. |