Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,21 @@ protected override int ExecuteInternal()
return command.ExecuteNonQuery();
}

protected override Task<int> ExecuteInternalAsync(CancellationToken token = default)
protected async override Task<int> ExecuteInternalAsync(CancellationToken token = default)
{
if (PrimaryIndexes.Length > 1) {
throw new NotImplementedException("Inheritance is not implemented");
}

base.ExecuteInternal();
_ = base.ExecuteInternal();

var request = GetRequest(query);
Bindings = request.ParameterBindings.ToList();

var command = CreateCommand(request);
return command.ExecuteNonQueryAsync(token);
await using (command.ConfigureAwait(false)) {
return await command.ExecuteNonQueryAsync(token).ConfigureAwait(false);
}
}

private QueryCommand CreateCommand(QueryTranslationResult request)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2019-2020 Xtensive LLC.
// Copyright (C) 2019-2020 Xtensive LLC.
// This code is distributed under MIT license terms.
// See the License.txt file in the project root for more information.

Expand Down Expand Up @@ -38,18 +38,20 @@ protected override int ExecuteInternal()
return command.ExecuteNonQuery();
}

protected override Task<int> ExecuteInternalAsync(CancellationToken token = default)
protected async override Task<int> ExecuteInternalAsync(CancellationToken token = default)
{
if (PrimaryIndexes.Length > 1) {
throw new NotImplementedException("Inheritance is not implemented");
}

base.ExecuteInternal();
_ = base.ExecuteInternal();
var request = GetRequest(query);
Bindings = request.ParameterBindings.ToList();

var command = CreateCommand(request);
return command.ExecuteNonQueryAsync(token);
await using (command.ConfigureAwait(false)) {
return await command.ExecuteNonQueryAsync(token).ConfigureAwait(false);
}
}

private QueryCommand CreateCommand(QueryTranslationResult request)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2019-2020 Xtensive LLC.
// Copyright (C) 2019-2020 Xtensive LLC.
// This code is distributed under MIT license terms.
// See the License.txt file in the project root for more information.

Expand Down Expand Up @@ -32,15 +32,17 @@ protected override int ExecuteInternal()
return command.ExecuteNonQuery();
}

protected override Task<int> ExecuteInternalAsync(CancellationToken token = default)
protected async override Task<int> ExecuteInternalAsync(CancellationToken token = default)
{
if (PrimaryIndexes.Length > 1) {
throw new NotImplementedException("Inheritance is not implemented");
}
Bindings = new List<QueryParameterBinding>();

var command = CreateCommand();
return command.ExecuteNonQueryAsync(token);
await using (command.ConfigureAwait(false)) {
return await command.ExecuteNonQueryAsync(token).ConfigureAwait(false);
}
}

private QueryCommand CreateCommand()
Expand Down
14 changes: 13 additions & 1 deletion Orm/Xtensive.Orm/Orm/Services/QueryBuilding/QueryCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace Xtensive.Orm.Services
/// Unlike <see cref="DbCommand"/> this type is aware of <see cref="Session.Events"/>
/// and does all necessary logging of executed SQL.
/// </summary>
public sealed class QueryCommand : IDisposable
public sealed class QueryCommand : IDisposable, IAsyncDisposable
{
private readonly StorageDriver driver;
private readonly Session session;
Expand Down Expand Up @@ -117,6 +117,18 @@ public void Dispose()
realCommand?.Dispose();
}

public ValueTask DisposeAsync()
{
if (disposed) {
return default;
}
disposed = true;
if (realCommand != null) {
return realCommand.DisposeAsync();
}
return default;
}

// Constructors

internal QueryCommand(StorageDriver driver, Session session, DbCommand realCommand)
Expand Down