Skip to content

Commit aaed110

Browse files
committed
Initialize transaction on CreateDbCommand()
1 parent c1984b8 commit aaed110

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionHelper.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,11 @@ override protected DbCommand CreateDbCommand()
159159
DbProviderFactory providerFactory = ConnectionFactory.ProviderFactory;
160160
command = providerFactory.CreateCommand();
161161
command.Connection = this;
162+
if (InnerConnection is SqlInternalConnection { CurrentTransaction: { Parent: {} transaction} })
163+
{
164+
command.Transaction = transaction;
165+
}
166+
162167
return command;
163168
}
164169
}

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionHelper.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,11 @@ override protected DbCommand CreateDbCommand()
205205
DbProviderFactory providerFactory = ConnectionFactory.ProviderFactory;
206206
DbCommand command = providerFactory.CreateCommand();
207207
command.Connection = this;
208+
if (InnerConnection is SqlInternalConnection { CurrentTransaction: { Parent: {} transaction} })
209+
{
210+
command.Transaction = transaction;
211+
}
212+
208213
return command;
209214
}
210215
}

0 commit comments

Comments
 (0)