Lets say I have these classes:
public class Foo
{
public DateTime Value { get; set; }
}
public class Bar
{
public Foo? Foo { get; set; }
}
Now if I do this projection:
var projection = Builders<Bar>.Projection.Expression(x => x.Foo!.Value)
I will get DateTime.MinValue and not a null in case Foo is null. The Value itself indeed cannot be null (and I assume that is why MongoDB is doing default(DateTime)), but the path to Value can be.
I am wondering if there is a good way to tell MongoDB that the result should be DateTime? so that I can get a null in case Foo does not exist.
P.S. I can make the Value DateTime?, and that will work but I would rather avoid it, since the Value itself should not ever be null.