Convert Async to sync (SqlClient apis) and cleanup async usage (#2167)

This commit is contained in:
Cheena Malhotra
2023-08-09 15:03:02 -07:00
committed by GitHub
parent 65a7406063
commit 0820d9796a
20 changed files with 64 additions and 83 deletions

View File

@@ -528,10 +528,10 @@ namespace Microsoft.SqlTools.ServiceLayer.EditData
{
// Get the command from the edit operation and execute it
using (DbCommand editCommand = editOperation.GetCommand(connection))
using (DbDataReader reader = await editCommand.ExecuteReaderAsync())
using (DbDataReader reader = editCommand.ExecuteReader())
{
// Apply the changes of the command to the result set
await editOperation.ApplyChanges(reader);
editOperation.ApplyChanges(reader);
}
}
catch (EditDataDeleteException)

View File

@@ -12,7 +12,6 @@ using System.Data.Common;
using Microsoft.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SqlTools.ServiceLayer.EditData.Contracts;
using Microsoft.SqlTools.ServiceLayer.QueryExecution;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
@@ -74,11 +73,11 @@ namespace Microsoft.SqlTools.ServiceLayer.EditData.UpdateManagement
/// Reader returned from the execution of the command to insert a new row. Should contain
/// a single row that represents the newly added row.
/// </param>
public override Task ApplyChanges(DbDataReader dataReader)
public override void ApplyChanges(DbDataReader dataReader)
{
Validate.IsNotNull(nameof(dataReader), dataReader);
return AssociatedResultSet.AddRow(dataReader);
AssociatedResultSet.AddRow(dataReader);
}
/// <summary>

View File

@@ -9,7 +9,6 @@ using System;
using System.Data.Common;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.SqlTools.ServiceLayer.EditData.Contracts;
using Microsoft.SqlTools.ServiceLayer.QueryExecution;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
@@ -71,11 +70,10 @@ namespace Microsoft.SqlTools.ServiceLayer.EditData.UpdateManagement
/// Reader returned from the execution of the command to insert a new row. Should NOT
/// contain any rows.
/// </param>
public override Task ApplyChanges(DbDataReader dataReader)
public override void ApplyChanges(DbDataReader dataReader)
{
// Take the result set and remove the row from it
AssociatedResultSet.RemoveRow(RowId);
return Task.FromResult(0);
}
/// <summary>

View File

@@ -10,7 +10,6 @@ using System.Collections.Generic;
using System.Data.Common;
using Microsoft.Data.SqlClient;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.SqlTools.ServiceLayer.EditData.Contracts;
using Microsoft.SqlTools.ServiceLayer.QueryExecution;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
@@ -86,7 +85,7 @@ namespace Microsoft.SqlTools.ServiceLayer.EditData.UpdateManagement
/// <param name="dataReader">
/// Data reader from execution of the command to commit the change to the db
/// </param>
public abstract Task ApplyChanges(DbDataReader dataReader);
public abstract void ApplyChanges(DbDataReader dataReader);
/// <summary>
/// Gets a command that will commit the change to the db

View File

@@ -14,7 +14,6 @@ using Microsoft.Data.SqlClient;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SqlTools.ServiceLayer.EditData.Contracts;
using Microsoft.SqlTools.ServiceLayer.QueryExecution;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
@@ -74,10 +73,10 @@ namespace Microsoft.SqlTools.ServiceLayer.EditData.UpdateManagement
/// Reader returned from the execution of the command to update a row. Should contain
/// a single row that represents all the values of the row.
/// </param>
public override Task ApplyChanges(DbDataReader dataReader)
public override void ApplyChanges(DbDataReader dataReader)
{
Validate.IsNotNull(nameof(dataReader), dataReader);
return AssociatedResultSet.UpdateRow(RowId, dataReader);
AssociatedResultSet.UpdateRow(RowId, dataReader);
}
/// <summary>