Summary
Attempting to access a member of a DateTime type (Year, Month, Day, etc) fails with exception:
System.NotSupportedException: 'Serializer for System.DateTime must implement IBsonDocumentSerializer to be used with LINQ.'
thrown from MemberExpressionToAggregationTranslator.Translate.
I stepped through and found that within MemberExpressionToAggregationExpressionTranslator.TryTranslateDateTimeProperty the 'container.Expression.Type' value is the type of '.Year', not the parent DateTime and as such fails the type check. The 'container.Expression.Expression.Type' is DateTime however so maybe it's just looking at the wrong expression.
This access worked in V2 so I assume DateTime component access is still intended.
How to Reproduce
With an IQueryable<DateTime> attempt to access '.Year'
Additional Background
I've included a screen cap of the locals within the TryTranslateDateTimeProperty __
- backports
-
CSHARP-4743 Add support for DateTime.Date and DateTime.TimeOfDay
- Closed