[CSHARP-4469] LINQ support for `switch-case` expression Created: 26/Dec/22 Updated: 30/Dec/22 Resolved: 30/Dec/22 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | None |
| Affects Version/s: | 2.18.0 |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Unknown |
| Reporter: | LeaFrock N/A | Assignee: | Robert Stam |
| Resolution: | Won't Do | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
How to use `$switch`/`$branch`/`$case` with LINQ v3? I find that `p => p.Mode == 1 ? "A" : "B"` will be translated into `$cond`/`$if`/`$else`. But currently it seems does not support `switch` pattern:
Any possibility to implement it? Or did I miss something already documented before? Thanks in advance. |
| Comments |
| Comment by LeaFrock N/A [ 30/Dec/22 ] | |
|
So we cannot generate `$switch`/`$branch`/`$case` commands with LINQ unless Microsoft adds support for switch expressions, right?
That sounds | |
| Comment by Robert Stam [ 30/Dec/22 ] | |
|
If Microsoft adds support for switch expressions in expression trees we will reopen this ticket. | |
| Comment by Robert Stam [ 30/Dec/22 ] | |
|
I started trying to implement support for switch expressions in LINQ queries but immediately ran into the limitation that Expression has no support for switch expressions. I got the following compile time error:
So this feature request is not possible yet. | |
| Comment by Robert Stam [ 26/Dec/22 ] | |
|
Thank you for the suggestion. This is not currently supported, but it would be nice to support it if possible. I will investigate further.. |