コード例 #1
0
    public async Task SuccessWithoutRecordsAffected()
    {
        await EmptyTable();

        var csb = BuildConnectionStringBuilder(ServerType, Compression, WireCrypt);

        csb.ReturnRecordsAffected = false;

        await using (var conn = new FbConnection(csb.ToString()))
        {
            await conn.OpenAsync();

            await using (var cmd = conn.CreateBatchCommand())
            {
                cmd.CommandText = "insert into batch (i) values (@i)";
                var batch1 = cmd.AddBatchParameters();
                batch1.Add("i", 1);
                var batch2 = cmd.AddBatchParameters();
                batch2.Add("i", 2);
                var result = await cmd.ExecuteNonQueryAsync();

                Assert.AreEqual(2, result.Count);
                Assert.IsTrue(result.AllSuccess);
                Assert.IsTrue(result[0].IsSuccess);
                Assert.IsNull(result[0].Exception);
                Assert.AreEqual(-1, result[0].RecordsAffected);
                Assert.IsTrue(result[1].IsSuccess);
                Assert.IsNull(result[1].Exception);
                Assert.AreEqual(-1, result[1].RecordsAffected);
            }
        }
    }