Bug #103436 SqlNullabilityProcessor error when using EF and filter by Date/Time
| Submitted: | 23 Apr 2021 2:44 | Modified: | 25 Jan 2022 23:10 |
|---|---|---|---|
| Reporter: | Guillermo Perez | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | Connector / NET | Severity: | S2 (Serious) |
| Version: | 5.0.3+MySQL8.0.24 | OS: | Windows |
| Assigned to: | CPU Architecture: | Any | |
| Tags: | .net, core, date, EF, SqlNullabilityProcessor, time | ||
[23 Apr 2021 2:44]
Guillermo Perez
[23 Apr 2021 2:44]
Guillermo Perez
My program screenshot
Attachment: screenshot.png (image/png, text), 68.43 KiB.
[23 Apr 2021 12:34]
MySQL Verification Team
Hello Guillermo Perez, Thank you for the bug report. Could you please provide repeatable test case (sample project, etc. - please make it as private if you prefer) to confirm this issue at our end? Regards, Ashwini Patil
[23 May 2021 15:24]
Erik Steinvall
I seem to have the same problem. The problem seems to occur when trying to compare dates when there is a posibility of there being no date to compare to (ie. table being empty, other criteria not resulting in a match etc.) I have tried both "t.LastUpdated < DateTime.Now.AddDays(-7)" and "t.LastUpdated.AddDays(7) < DateTime.Now" I have also tried making the field "LastUpdated" nullable and checking if the value is null before trying to compare the dates but that did not help.
[1 Jun 2021 11:06]
Chris Mason
Hi OP, hopefully you see this reply. I had exactly the same error as you and found a remarkably simple way to get around it. Instead of defining the datetime in the where clause, create a separate variable:
var dt = datetime.now.addDays(-15);
var Ads = mySqlDbContext.MyTable.Where(
w => w.PostType == "mytext"
&& w.PostStatus == "activeText"
&& w.PostCreated >= dt
);
This worked fine for me with no errors reported. Hope this helps.
[4 Jun 2021 11:01]
MySQL Verification Team
Hello Guillermo Perez, Thank you for the bug report and feedback. Discussed this issue internally with the developer and confirmed that this is a bug and the workaround suggested by Chris Mason seems to work. Hence, in the meantime I suggest you to use the workaround until issue is fixed. Thank you! Regards, Ashwini Patil
[25 Jan 2022 23:10]
Christine Cole
Posted by developer: Fixed as of the upcoming MySQL Connector/NET 8.0.29 release, and here's the proposed changelog entry from the documentation team: When comparing a date-time LINQ expression against a database date field, Connector/NET returned an invalid operation exception due to unavailable classes that are required for an application to filter using EF Core. Thank you for the bug report.
[29 Apr 2022 10:47]
MySQL Verification Team
Bug #106520 marked as duplicate of this one.
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.109 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.