Skip to content

Commit 5c7cfc9

Browse files
committed
resolve conflict
1 parent f18fbf7 commit 5c7cfc9

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

src/Ydb.Sdk/src/Ado/YdbCommand.cs

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,31 @@ protected override async Task<DbDataReader> ExecuteDbDataReaderAsync(CommandBeha
217217
throw new InvalidOperationException("Transaction mismatched! (Maybe using another connection)");
218218
}
219219

220-
var ydbDataReader = await YdbDataReader.CreateYdbDataReader(await YdbConnection.Session.ExecuteQuery(
221-
preparedSql.ToString(), ydbParameters, execSettings, transaction?.TransactionControl
222-
), YdbConnection.OnNotSuccessStatusCode, transaction, cancellationToken);
220+
var useImplicit = YdbConnection.EnableImplicitSession && transaction is null;
221+
var session = YdbConnection.GetExecutionSession(useImplicit);
222+
223+
YdbDataReader ydbDataReader;
224+
try
225+
{
226+
var execResult = await session.ExecuteQuery(
227+
preparedSql.ToString(),
228+
ydbParameters,
229+
execSettings,
230+
transaction?.TransactionControl
231+
);
232+
233+
ydbDataReader = await YdbDataReader.CreateYdbDataReader(
234+
execResult,
235+
YdbConnection.OnNotSuccessStatusCode,
236+
transaction,
237+
cancellationToken
238+
);
239+
}
240+
finally
241+
{
242+
if (useImplicit)
243+
session.Close();
244+
}
223245

224246
YdbConnection.LastReader = ydbDataReader;
225247
YdbConnection.LastCommand = CommandText;

0 commit comments

Comments
 (0)