0

I'm having trouble with nullable dates. At first my model included this field:

public DateTime CompletedDateTime { get; set; }

When I changed it to...

public DateTime? CompletedDateTime { get; set; }

...and did a migration, everything seemed to work okay at first. This was only because field CompletedDateTime had a date in it. When I had a record that had a NULL in that field, any PUSH or PULL operations freeze up and the log in Azure Portal is very vague and simply says there's a 400 Bad Request because of a malformed request. It can happen if I set the NULL in my local offline table (then try a pushitemsasync) OR in Azure (then a pullitemsasync).

I did notice that EFFrameworkCore is generating a "datetime2(7) NULL" from a DateTime? in C#. I'm not sure if this has anything to do with the issue.

I'm using .NET 8, MAUI version 8.0.60, Datasync client 6.1.0 and EF Framework Core 8.0.1

4
  • I changed the datetime2(7) to datetime and it still does the same thing.
    – iPaul
    Commented Nov 26 at 21:06
  • Aside... datetime (Transact-SQL) Avoid using datetime for new work. Instead, use the time, date, datetime2, and datetimeoffset data types. The datetime data type is a legacy left over from when SQL Server was Sybase and will cause you difficulties at some point due to its 1/300th second imprecision. Commented Nov 26 at 22:05
  • You mentioned "date" a few times in your question. Do you need the time component of DateTime, or should you be using DateOnly instead? Commented Nov 26 at 22:08
  • Sorry, I tend to use those terms interchangeably. But in this case, I do want to keep the time component as well. Regarding your 1st comment, thanks for the explanation of how the types differ. I just can't get past this issue. It seems like a datasync bug but I can't be sure.
    – iPaul
    Commented Nov 26 at 22:28

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.