dotnetcore / dotnetcore/FreeSql

字典插入中日期字段存在bug

Open
#1,885 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
4.4k
Forks
910
PR merge metrics
No merged PRs in 30d

Description

#### 问题描述及重现代码:
Table数据表中存在日期字段,在使用 InsertDict 插入多行数据时,有些行数据的日期字段有值,有些为空值,在插入数据库后,空值的字段值被插入成了固定值“1970-01-01 00:00:00.000”

```c#
// c# code
```
fsql.InsertDict(dic).AsTable("tableName").ExecuteAffrows();

#### 数据库版本
SqlServer 2012

#### 安装的Nuget包

#### .net framework/. net core? 及具体版本
.Net 6

![微信图片_20240913194158](https://github.com/user-attachments/assets/3074c6af-f353-450b-b252-c31b806999ae)

![微信图片_20240913194159](https://github.com/user-attachments/assets/53f85eb0-6b5c-4b4a-8e81-a53ee28b4862)

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)

数据库中的表字段也是允许为空值的
![微信截图_20240913194913](https://github.com/user-attachments/assets/55d2e367-0844-4357-8425-1e1791b80fec)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.