Skip to content

CreateCommand sets Transaction property #389

@bgrainger

Description

@bgrainger

Consider the following code:

using (var connection = new XConnection(...))
{
     connection.Open();
    using (var transaction = connection.BeginTransaction())
    using (var cmd = connection.CreateCommand()
    {
        Console.WriteLine(cmd.Transaction == null);
    }
}

Connector/NET, SqlConnection and NpgsqlConnection all print true; MySqlConnector prints false because .Transaction is set to the active transaction. We should follow the pattern of other ADO.NET connectors and require .Transaction to be set explicitly.

It's possible this could be affecting #333 if commands are being created with an active transaction, then used again after that transaction is committed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions