Setting with a ternary
DateTime filterDate = endDate.HasValue ? endDate.Value : DateTime.Now.AddDays(7);
Non ternary
DateTime filterDate;
if (endDate.HasValue)
filterDate = endDate.Value;
else
filterDate = DateTime.Now.AddDays(7);
If you debug these two statements the value of filterDate will not be the same. Why is this?
In the first example filterDate ends up with a value of 01/01/0001. In the second example I get the expected result which is filterDate is a datetime 7 days in the future.
EDIT: At this point I've even tried setting endDate = null just to make sure and here is a screen shot of what happens.
Strangest thing I've ever seen.