File tree Expand file tree Collapse file tree 4 files changed +29
-11
lines changed
Extensions/Xtensive.Orm.BulkOperations/Internals
Orm/Xtensive.Orm/Orm/Services/QueryBuilding Expand file tree Collapse file tree 4 files changed +29
-11
lines changed Original file line number Diff line number Diff line change @@ -34,19 +34,21 @@ protected override int ExecuteInternal()
3434 return command . ExecuteNonQuery ( ) ;
3535 }
3636
37- protected override Task < int > ExecuteInternalAsync ( CancellationToken token = default )
37+ protected async override Task < int > ExecuteInternalAsync ( CancellationToken token = default )
3838 {
3939 if ( PrimaryIndexes . Length > 1 ) {
4040 throw new NotImplementedException ( "Inheritance is not implemented" ) ;
4141 }
4242
43- base . ExecuteInternal ( ) ;
43+ _ = base . ExecuteInternal ( ) ;
4444
4545 var request = GetRequest ( query ) ;
4646 Bindings = request . ParameterBindings . ToList ( ) ;
4747
4848 var command = CreateCommand ( request ) ;
49- return command . ExecuteNonQueryAsync ( token ) ;
49+ await using ( command . ConfigureAwait ( false ) ) {
50+ return await command . ExecuteNonQueryAsync ( token ) . ConfigureAwait ( false ) ;
51+ }
5052 }
5153
5254 private QueryCommand CreateCommand ( QueryTranslationResult request )
Original file line number Diff line number Diff line change 1- // Copyright (C) 2019-2020 Xtensive LLC.
1+ // Copyright (C) 2019-2020 Xtensive LLC.
22// This code is distributed under MIT license terms.
33// See the License.txt file in the project root for more information.
44
@@ -38,18 +38,20 @@ protected override int ExecuteInternal()
3838 return command . ExecuteNonQuery ( ) ;
3939 }
4040
41- protected override Task < int > ExecuteInternalAsync ( CancellationToken token = default )
41+ protected async override Task < int > ExecuteInternalAsync ( CancellationToken token = default )
4242 {
4343 if ( PrimaryIndexes . Length > 1 ) {
4444 throw new NotImplementedException ( "Inheritance is not implemented" ) ;
4545 }
4646
47- base . ExecuteInternal ( ) ;
47+ _ = base . ExecuteInternal ( ) ;
4848 var request = GetRequest ( query ) ;
4949 Bindings = request . ParameterBindings . ToList ( ) ;
5050
5151 var command = CreateCommand ( request ) ;
52- return command . ExecuteNonQueryAsync ( token ) ;
52+ await using ( command . ConfigureAwait ( false ) ) {
53+ return await command . ExecuteNonQueryAsync ( token ) . ConfigureAwait ( false ) ;
54+ }
5355 }
5456
5557 private QueryCommand CreateCommand ( QueryTranslationResult request )
Original file line number Diff line number Diff line change 1- // Copyright (C) 2019-2020 Xtensive LLC.
1+ // Copyright (C) 2019-2020 Xtensive LLC.
22// This code is distributed under MIT license terms.
33// See the License.txt file in the project root for more information.
44
@@ -32,15 +32,17 @@ protected override int ExecuteInternal()
3232 return command . ExecuteNonQuery ( ) ;
3333 }
3434
35- protected override Task < int > ExecuteInternalAsync ( CancellationToken token = default )
35+ protected async override Task < int > ExecuteInternalAsync ( CancellationToken token = default )
3636 {
3737 if ( PrimaryIndexes . Length > 1 ) {
3838 throw new NotImplementedException ( "Inheritance is not implemented" ) ;
3939 }
4040 Bindings = new List < QueryParameterBinding > ( ) ;
4141
4242 var command = CreateCommand ( ) ;
43- return command . ExecuteNonQueryAsync ( token ) ;
43+ await using ( command . ConfigureAwait ( false ) ) {
44+ return await command . ExecuteNonQueryAsync ( token ) . ConfigureAwait ( false ) ;
45+ }
4446 }
4547
4648 private QueryCommand CreateCommand ( )
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ namespace Xtensive.Orm.Services
1818 /// Unlike <see cref="DbCommand"/> this type is aware of <see cref="Session.Events"/>
1919 /// and does all necessary logging of executed SQL.
2020 /// </summary>
21- public sealed class QueryCommand : IDisposable
21+ public sealed class QueryCommand : IDisposable , IAsyncDisposable
2222 {
2323 private readonly StorageDriver driver ;
2424 private readonly Session session ;
@@ -117,6 +117,18 @@ public void Dispose()
117117 realCommand ? . Dispose ( ) ;
118118 }
119119
120+ public ValueTask DisposeAsync ( )
121+ {
122+ if ( disposed ) {
123+ return default ;
124+ }
125+ disposed = true ;
126+ if ( realCommand != null ) {
127+ return realCommand . DisposeAsync ( ) ;
128+ }
129+ return default ;
130+ }
131+
120132 // Constructors
121133
122134 internal QueryCommand ( StorageDriver driver , Session session , DbCommand realCommand )
You can’t perform that action at this time.
0 commit comments