Repository: dotnet/efcore
File: test/Microsoft.Data.Sqlite.Tests/SqliteDataReaderTest.cs (C#)

Code before:

    [Fact]
    public void RecordsAffected_works_with_returning_multiple()
    {
        using (var connection = new SqliteConnection("Data Source=:memory:"))
        {
            if (new Version(connection.ServerVersion) < new Version(3, 35, 0))
            {
                // Skip. RETURNING clause not supported
                return;
            }

            connection.Open();
            connection.ExecuteNonQuery("CREATE TABLE Test(Value);");

            var reader = connection.ExecuteReader("INSERT INTO Test VALUES(1),(2) RETURNING rowid;");
            ((IDisposable)reader).Dispose();

            Assert.Equal(2, reader.RecordsAffected);
        }
    }

    [Fact]
    public void RecordsAffected_not_affected_by_DDL_statements()
    {
        using var connection = new SqliteConnection("Data Source=:memory:");
        connection.Open();

        using (var reader = connection.ExecuteReader(
            @"CREATE TABLE foo(bar TEXT NOT NULL);
              CREATE TABLE xyz(aaa TEXT NOT NULL);
              INSERT INTO foo(bar) VALUES('baz');
              INSERT INTO foo(bar) VALUES('baz2');
              DROP TABLE xyz;"))
        {
            Assert.Equal(2, reader.RecordsAffected);
        }
    }

    [Fact]
    public void RecordsAffected_not_affected_by_DDL_statements_with_drop_and_create()
    {
        using var connection = new SqliteConnection("Data Source=:memory:");
        connection.Open();

        connection.ExecuteNonQuery("CREATE TABLE foo(bar TEXT NOT NULL);");

        using (var reader = connection.ExecuteReader(
            @"DROP TABLE foo;
              CREATE TABLE foo(bar TEXT NOT NULL);
              CREATE TABLE xyz(aaa TEXT NOT NULL);

Review comment (suggestion):
To be consistent with rest of the file, use `using (var connection = new SqliteConnection("Data Source=:memory:"))`, aka with block.

Code after:

    [Fact]
    public void RecordsAffected_works_with_returning_multiple()
    {
        using (var connection = new SqliteConnection("Data Source=:memory:"))
        {
            if (new Version(connection.ServerVersion) < new Version(3, 35, 0))
            {
                // Skip. RETURNING clause not supported
                return;
            }

            connection.Open();
            connection.ExecuteNonQuery("CREATE TABLE Test(Value);");

            var reader = connection.ExecuteReader("INSERT INTO Test VALUES(1),(2) RETURNING rowid;");
            ((IDisposable)reader).Dispose();

            Assert.Equal(2, reader.RecordsAffected);
        }
    }

    [Fact]
    public void RecordsAffected_not_affected_by_DDL_statements()
    {
        using (var connection = new SqliteConnection("Data Source=:memory:"))
        {
            connection.Open();

            using (var reader = connection.ExecuteReader(
                @"CREATE TABLE foo(bar TEXT NOT NULL);
                  CREATE TABLE xyz(aaa TEXT NOT NULL);
                  INSERT INTO foo(bar) VALUES('baz');
                  INSERT INTO foo(bar) VALUES('baz2');
                  DROP TABLE xyz;"))
            {
                Assert.Equal(2, reader.RecordsAffected);
            }
        }
    }

    [Fact]
    public void RecordsAffected_not_affected_by_DDL_statements_with_drop_and_create()
    {
        using (var connection = new SqliteConnection("Data Source=:memory:"))
        {
            connection.Open();

            using (var reader = connection.ExecuteReader(
                @"CREATE TABLE foo(bar TEXT NOT NULL);
                  CREATE TABLE xyz(aaa TEXT NOT NULL);