Switching from ISqlConnection to DbConnection

This is a fairly minor change that will save tons of time as we develop
this service. The DbConnection and associated Db* abstract classes
ask for synchronous versions of the code and allow the addition of async
code. The SqlClient implementation already implements Db* abstract
classes, so we can piggy back off that for our dependency injection layer.

Tests and existing code has been updated to handle the change, as well
This commit is contained in:
Benjamin Russell
2016-08-02 18:19:51 -07:00
parent f40aa31c67
commit b2f44031b7
8 changed files with 104 additions and 351 deletions

View File

@@ -6,10 +6,9 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Threading.Tasks;
using Microsoft.SqlTools.ServiceLayer.ConnectionServices;
using Microsoft.SqlTools.ServiceLayer.ConnectionServices.Contracts;
using Microsoft.SqlTools.ServiceLayer.Hosting;
using Microsoft.SqlTools.ServiceLayer.LanguageServices.Contracts;
using Microsoft.SqlTools.ServiceLayer.WorkspaceServices.Contracts;
@@ -66,16 +65,16 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
/// TODO: Update with refactoring/async
/// </summary>
/// <param name="connection"></param>
public async Task UpdateAutoCompleteCache(ISqlConnection connection)
public async Task UpdateAutoCompleteCache(DbConnection connection)
{
IDbCommand command = connection.CreateCommand();
DbCommand command = connection.CreateCommand();
command.CommandText = "SELECT name FROM sys.tables";
command.CommandTimeout = 15;
command.CommandType = CommandType.Text;
var reader = command.ExecuteReader();
var reader = await command.ExecuteReaderAsync();
List<string> results = new List<string>();
while (reader.Read())
while (await reader.ReadAsync())
{
results.Add(reader[0].ToString());
}