mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-09 01:32:38 -05:00
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:
@@ -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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user