0
我有一個C#應用程序,它使用NpgSQL與postgres數據庫進行通信。但是,當我嘗試用包含NULL值的結果填充DataTable時,將引發錯誤:從NpgSQL加載空值時出現DataTable約束錯誤
「System.Data.ConstraintException:'無法啓用約束。一個或多個行包含違反非null的值,唯一或外鍵約束'」
這甚至當我做這樣的事情:
NpgsqlCommand statement = new NpgsqlCommand("SELECT NULL", connection);
NpgsqlDataReader resultReader = statement.ExecuteReader();
var table = new DataTable();
table.Load(resultReader);
在Visual Studio命令窗口,table.GetErrors()[0]`給:
{System.Data.DataRow}
HasErrors: true
ItemArray: {object[1]}
RowError: "Column '?column?' does not allow DBNull.Value."
RowState: Unchanged
Table: {}
這可能與this bug有關嗎?