OrchardCMS / Orchard

Orchard is a free, open source, community-focused Content Management System built on the ASP.NET MVC platform.
https://orchardproject.net
BSD 3-Clause "New" or "Revised" License
2.37k stars 1.12k forks source link

UtcDateTime expect date kind Utc but it is Unspecified #8635

Open MatteoPiovanelli-Laser opened 1 year ago

MatteoPiovanelli-Laser commented 1 year ago

This kind of exception is thrown by somequery on the dev branch.

I've tracked it down, and it seems related to https://github.com/OrchardCMS/Orchard/blob/ca86ec98316f6fa3a3b561cf83eae98b14988dae/src/Orchard/Data/Conventions/UtcDateTimeConvention.cs#L13 (basically, if a property in a record is a DateTime and its name ends with "Utc", in NHibernate the type would be DateTimeType, rather than DateTimeType) and the fact that nHibernate version 5.x (that is in dev since January) enforces that type more strongly.

I have already tested locally a fix in a NHibernateExpressionVisitor that would allow Orchard to handle that cleanly and seems to work for all cases (all that I've been able to test).

I was wondering whether @sebastienros remembers if that convention there is important, because I have a feeling that removing it would also fix this issue.

MatteoPiovanelli-Laser commented 1 year ago

Correction: removing the convention doesn't seem to work at all. I'm not sure why and can't investigate it right now.