Commit 34a149e5 authored by 潘栩锋's avatar 潘栩锋 🚴

修复 SQLiteHelper.SQLiteDbContext 当表没有数据 FreeID 出错

parent 8e287a49
...@@ -88,7 +88,10 @@ namespace SQLite ...@@ -88,7 +88,10 @@ namespace SQLite
{ {
string cmd = $"SELECT MAX(ID) FROM {tablename}"; string cmd = $"SELECT MAX(ID) FROM {tablename}";
var reponse = sqliteHelper.ExecuteScalar(cmd); var reponse = sqliteHelper.ExecuteScalar(cmd);
return System.Convert.ToInt64(reponse) + 1; if (reponse is DBNull)
return 0;
else
return System.Convert.ToInt64(reponse) + 1;
} }
......
...@@ -131,5 +131,7 @@ namespace UnitTestProject1 ...@@ -131,5 +131,7 @@ namespace UnitTestProject1
} }
Assert.IsNull(ex); Assert.IsNull(ex);
} }
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment