[CSHARP-4572] Casting from an interface to a concrete type in a filter expression fails Created: 17/Mar/23 Updated: 21/Apr/23 |
|
| Status: | Backlog |
| Project: | C# Driver |
| Component/s: | LINQ3 |
| Affects Version/s: | 2.19.0 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Unknown |
| Reporter: | Chris Venus | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | triage | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
The following code fails in Linq V3 but works if I cahnge to LINQ v2:
Classes and interfaces are very basic and as follows:
When LinqProvider is set to V2 it correctly outputs
If I run the code with the V3 provider I get:
My assumption is that the issue lies in the code in ConvertExpressionToFilterFieldTranslator where IsConvertToDerivedType feels like it should return true but because it checks for IsSubclassOf rather than IsAssignableFrom it decides that it can't convert. Also I am aware that I can rewrite this using OfType but I figure if it works in V2 then it should work in V3 too.
|