[CSHARP-2321] exclude an member/field when use Expression to create Projection Definition Created: 06/Jul/18 Updated: 27/Oct/23 Resolved: 15/Jan/19 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | Feature Request |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | Hongbo Liu | Assignee: | Robert Stam |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
For example,
We can create the ProjectionDefinition like this:
How about we want to use the expression to exclude a memeber/field? Can we support something like this:
Basically in the expression, if the right-hand operand is default(T), we treat it as excluded field/member. Is that possible? |
| Comments |
| Comment by Robert Stam [ 15/Jan/19 ] | ||||
|
It's an interesting thought, but I don't think it will work. Consider that the result of the projection (the TProjection type parameter) is by definition the same as the result type of the expression. In your second example TProjection will be an anonymous type like:
In other words, the result type would contain only the Name, rather than all fields except the Name.
|