Details
-
Improvement
-
Resolution: Works as Designed
-
Minor - P4
-
None
-
None
-
None
Description
For example,
class Widget |
{
|
[BsonElement("x")] |
public int X { get; set; } |
|
|
[BsonElement("y")] |
public int Y { get; set; } |
|
|
[BsonElement("name")] |
public string Name { get; set; } |
}
|
We can create the ProjectionDefinition like this:
var projection = Builders<Widget>.Projection<Widget>.Expression(x => new { X = x.X, Y = x.Y }); |
|
How about we want to use the expression to exclude a memeber/field?
Can we support something like this:
var projection = Builders<Widget>.Projection<Widget>.Expression(x => new { Name = null }); |
Basically in the expression, if the right-hand operand is default(T), we treat it as excluded field/member.
Is that possible?