我在NpgSqlCopyIn行上得到null异常。
序列化程序不是null但是ToStream是 - 为什么?
string connstring = String.Format("Server={0};Port={1};User Id={2};Password={3};Database={4};", <removed creds>);
NpgsqlConnection dbcon = new NpgsqlConnection(connstring);
NpgsqlCommand dbcmd = dbcon.CreateCommand();
string sql = "COPY MIN_BAR_LASTS FROM STDIN;";
dbcmd.CommandText = sql;
NpgsqlCopySerializer serializer = new NpgsqlCopySerializer(dbcon);
NpgsqlCopyIn copyIn = new NpgsqlCopyIn(dbcmd, dbcon, serializer.ToStream);
copyIn.Start();
var lines = File.ReadAllLines(@"C:\PostgreSQLLoadFile.txt");
foreach(var line in lines){
serializer.AddString(line);
serializer.EndRow();
serializer.Flush();
}
copyIn.End();
serializer.Close();