本文整理汇总了C#中Npgsql.NpgsqlConnection.BeginRawBinaryCopy方法的典型用法代码示例。如果您正苦于以下问题:C# NpgsqlConnection.BeginRawBinaryCopy方法的具体用法?C# NpgsqlConnection.BeginRawBinaryCopy怎么用?C# NpgsqlConnection.BeginRawBinaryCopy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Npgsql.NpgsqlConnection
的用法示例。
在下文中一共展示了NpgsqlConnection.BeginRawBinaryCopy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CancelRawBinaryImport
public void CancelRawBinaryImport()
{
using (var conn = new NpgsqlConnection(ConnectionString))
{
conn.Open();
ExecuteNonQuery("CREATE TEMP TABLE data (field_text TEXT, field_int2 SMALLINT, field_int4 INTEGER)", conn);
var garbage = new byte[] {1, 2, 3, 4};
using (var s = conn.BeginRawBinaryCopy("COPY data (field_text, field_int4) FROM STDIN BINARY"))
{
s.Write(garbage, 0, garbage.Length);
s.Cancel();
}
Assert.That(ExecuteScalar("SELECT COUNT(*) FROM data", conn), Is.EqualTo(0));
}
}
示例2: CloseDuringCopy
public void CloseDuringCopy()
{
// TODO: Check no broken connections were returned to the pool
using (var conn = new NpgsqlConnection(ConnectionString)) {
conn.Open();
ExecuteNonQuery("CREATE TEMP TABLE data (field_text TEXT, field_int2 SMALLINT, field_int4 INTEGER)", conn);
conn.BeginBinaryImport("COPY data (field_text, field_int4) FROM STDIN BINARY");
}
using (var conn = new NpgsqlConnection(ConnectionString)) {
conn.Open();
ExecuteNonQuery("CREATE TEMP TABLE data (field_text TEXT, field_int2 SMALLINT, field_int4 INTEGER)", conn);
conn.BeginBinaryExport("COPY data (field_text, field_int2) TO STDIN BINARY");
}
using (var conn = new NpgsqlConnection(ConnectionString)) {
conn.Open();
ExecuteNonQuery("CREATE TEMP TABLE data (field_text TEXT, field_int2 SMALLINT, field_int4 INTEGER)", conn);
conn.BeginRawBinaryCopy("COPY data (field_text, field_int4) FROM STDIN BINARY");
}
using (var conn = new NpgsqlConnection(ConnectionString)) {
conn.Open();
ExecuteNonQuery("CREATE TEMP TABLE data (field_text TEXT, field_int2 SMALLINT, field_int4 INTEGER)", conn);
conn.BeginRawBinaryCopy("COPY data (field_text, field_int4) TO STDIN BINARY");
}
using (var conn = new NpgsqlConnection(ConnectionString)) {
conn.Open();
ExecuteNonQuery("CREATE TEMP TABLE data (field_text TEXT, field_int2 SMALLINT, field_int4 INTEGER)", conn);
conn.BeginTextImport("COPY data (field_text, field_int4) FROM STDIN");
}
using (var conn = new NpgsqlConnection(ConnectionString)) {
conn.Open();
ExecuteNonQuery("CREATE TEMP TABLE data (field_text TEXT, field_int2 SMALLINT, field_int4 INTEGER)", conn);
conn.BeginTextExport("COPY data (field_text, field_int4) TO STDIN");
}
}