We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Table数据表中存在日期字段,在使用 InsertDict 插入多行数据时,有些行数据的日期字段有值,有些为空值,在插入数据库后,空值的字段值被插入成了固定值“1970-01-01 00:00:00.000”
// c# code
fsql.InsertDict(dic).AsTable("tableName").ExecuteAffrows();
SqlServer 2012
.Net 6
ToSql()的语句如下
INSERT INTO [T_Pai_FormTest_SubLister]([T_Pai_FormTestID], [ID], [SubCheckBox], [SubTextBox], [SubTextArea], [SubDatePicker], [SubComboBox], [SubButtonEdit], [SubButtonEditName], [SubSingleFile], [SubSingleFileName], [SubSpinner], [SortIndex], [IsReleased], [UpperVersionID]) VALUES(N'b1ea0143-d55c-4e0f-9412-0c9ec1c25eb7', N'b1ea0143-e1ec-45c8-93f4-3afaa89f9eed', NULL, N'数据行1', NULL, '2024-09-13 00:00:00.000', NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL), (N'b1ea0143-d55c-4e0f-9412-0c9ec1c25eb7', N'b1ea0143-e1ec-4657-8a7f-f2ea4762582c', NULL, N'数据行2', NULL, '1970-01-01 00:00:00.000', NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL)
数据库中的表字段也是允许为空值的
The text was updated successfully, but these errors were encountered:
字典是什么值,请用 (DateTime?) 值,而不是用 DateTime
Sorry, something went wrong.
DateTime.MinValue 在一些数据库中,值超出了数据库的范围,会报错,且很常见。因此,如果是 MinValue将使用1970年1月1号插入。
当然,如果使用的是DateTime可空类型,传入的值是 null,就会直接插入 DBNull。
当我传入两条数据,其中一条日期有值,另一条时间值是空,空值会使用“1970-01-01 00:00:00.000”插入。 但是只有一条数据且为空是,就不会出现这种情况。
No branches or pull requests
问题描述及重现代码:
Table数据表中存在日期字段,在使用 InsertDict 插入多行数据时,有些行数据的日期字段有值,有些为空值,在插入数据库后,空值的字段值被插入成了固定值“1970-01-01 00:00:00.000”
// c# code
fsql.InsertDict(dic).AsTable("tableName").ExecuteAffrows();
数据库版本
SqlServer 2012
安装的Nuget包
.net framework/. net core? 及具体版本
.Net 6
ToSql()的语句如下
INSERT INTO [T_Pai_FormTest_SubLister]([T_Pai_FormTestID], [ID], [SubCheckBox], [SubTextBox], [SubTextArea], [SubDatePicker], [SubComboBox], [SubButtonEdit], [SubButtonEditName], [SubSingleFile], [SubSingleFileName], [SubSpinner], [SortIndex], [IsReleased], [UpperVersionID]) VALUES(N'b1ea0143-d55c-4e0f-9412-0c9ec1c25eb7', N'b1ea0143-e1ec-45c8-93f4-3afaa89f9eed', NULL, N'数据行1', NULL, '2024-09-13 00:00:00.000', NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL), (N'b1ea0143-d55c-4e0f-9412-0c9ec1c25eb7', N'b1ea0143-e1ec-4657-8a7f-f2ea4762582c', NULL, N'数据行2', NULL, '1970-01-01 00:00:00.000', NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL)
数据库中的表字段也是允许为空值的
The text was updated successfully, but these errors were encountered: