Unusual cast required after upgrading to version 4.0.0
fabich opened this issue · 1 comments
fabich commented
Hi
After upgrading to version 4.0.0 (AutoMapper 10) we received the following error:
The binary operator Equal is not defined for the types 'System.DateTime' and 'System.Nullable`1DateTime
Example map:
Expression = x => (firstReleaseDate == null || x.StartDate >= firstReleaseDate) &&
(lastReleaseDate == null || x.StartDate <= lastReleaseDate)
Where firstReleaseDate and lastReleaseDate are DateTime? and x.StartDate is DateTime
"Weird" cast map that solved the issue:
Expression = x => ((DateTime?)firstReleaseDate == null || (DateTime?)x.StartDate >= (DateTime?)firstReleaseDate) &&
((DateTime?)lastReleaseDate == null || (DateTime?)x.StartDate <= (DateTime?)lastReleaseDate)
BlaiseD commented
You are correct - I broke it fixing Issue #79, another local variable issue. There's a preview version on nuget with a fix.
Thanks for posting.