Closed TheJayMann closed 5 years ago
After some analysis, it appears that this error occurs no matter which platform I am using, as it occurred with .NETCoreApp 2.1 and 2.0, as well as .NET Framework 4.7.2, both new and old msbuild formats. However, I had other projects which had no problem. I discovered the only difference between the two projects is one is using Sql Server 2016, and the other Sql Server 2010.
Based on this, My assumption is that option types are not supported in Sql Server 2010.
Can you just check the .IsNone
in the query and then use .Value
?
The query would become needlessly complex if I were to use do the check in the query itself, as this is mostly copying data from one table to another after performing some validation, and it involves 25 columns, all of them nullable, two of which are datetime, all others varchar.
Given that Option doesn't work, I simply used the fact that string type can be null, and that a null datetime translates to DateTime.MinValue, which is not a valid value for datetime, and can simply not set the column value in such case.
Description
When using the UseOptionTypes option with MSSQL, string columns do not properly return when returning the entire entity as is.
Repro steps
Expected behavior
It is expected that the results of the query be properly serialized into the return value of executing the query.
Actual behavior
A System.ArgumentException is thrown, stating that there is not a proper mapping type.
Known workarounds
By not using the UseOptionTypes option and using null for string values work as expected.
Related information
.NETCoreApp 2.2 SqlProvider 1.1.59