Skip to content

Commit ddf187c

Browse files
committed
TDengine TIMESTAMP特殊处理
1 parent 087288c commit ddf187c

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

FreeSql.Tests/FreeSql.Tests.Provider.TDengine/TDengine/TDengineIssue/TDengineIssueTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ void InsertTest1977()
4141
var insertAffrows = _fsql.Insert(new TDengineProcessMetrics1977()
4242
{
4343
Timestamp = DateTime.Now,
44-
HostName = "host6"
44+
HostName = "host1",
45+
StartTime = DateTime.Now
4546
}
4647
).ExecuteAffrows();
4748
Assert.Equal(1, insertAffrows);
4849
}
49-
5050
}
5151

5252
public class TDengineProcessMetrics1977
@@ -67,6 +67,6 @@ public class TDengineProcessMetrics1977
6767
/// 进程启动时间
6868
/// </summary>
6969
[Column(Name = "start_time")]
70-
public DateTime StartTime { get; set; }
70+
public DateTime? StartTime { get; set; }
7171
}
7272
}

Providers/FreeSql.Provider.TDengine/TDengineProvider.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,13 @@ public TDengineProvider(string masterConnectionString, string[] slaveConnectionS
5252
case "TIMESTAMP":
5353
try
5454
{
55-
var value = e.DataReader.GetValue(e.Index);
56-
if (value != null)
57-
e.Value = e.DataReader.GetDateTime(e.Index);
58-
else
59-
e.Value = null;
60-
55+
if (e.DataReader.IsDBNull(e.Index)) e.Value = null;
56+
else e.Value = e.DataReader.GetDateTime(e.Index);
6157
return;
6258
}
6359
catch
6460
{
65-
e.Value = new DateTime();
61+
e.Value = DateTime.MinValue;
6662
return;
6763
}
6864
}

0 commit comments

Comments
 (0)