diff --git a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.cs b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.cs index 118da69d..f523424f 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.cs @@ -8631,6 +8631,11 @@ namespace Microsoft.SqlTools.ServiceLayer return Keys.GetString(Keys.QueryServiceQueryFailed, message); } + public static string QueryServiceUnsupportedSqlVariantType(string underlyingType, string columnName) + { + return Keys.GetString(Keys.QueryServiceUnsupportedSqlVariantType, underlyingType, columnName); + } + public static string QueryServiceSaveAsFail(string fileName, string message) { return Keys.GetString(Keys.QueryServiceSaveAsFail, fileName, message); @@ -9021,6 +9026,9 @@ namespace Microsoft.SqlTools.ServiceLayer public const string QueryServiceResultSetTooLarge = "QueryServiceResultSetTooLarge"; + public const string QueryServiceUnsupportedSqlVariantType = "QueryServiceUnsupportedSqlVariantType"; + + public const string QueryServiceSaveAsResultSetNotComplete = "QueryServiceSaveAsResultSetNotComplete"; diff --git a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.resx b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.resx index ef3b7856..128499d6 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.resx +++ b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.resx @@ -303,6 +303,11 @@ Result set has too many rows to be safely loaded + + The underlying type "{0}" for sql variant column "{1}" could not be resolved. + . + Parameters: 0 - underlyingType (string), 1 - columnName (string) + Result cannot be saved until query execution has completed diff --git a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.strings b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.strings index b7cb98e9..a40d9dce 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.strings +++ b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.strings @@ -124,6 +124,8 @@ QueryServiceResultSetHasNoResults = Query has no results to return QueryServiceResultSetTooLarge = Result set has too many rows to be safely loaded +QueryServiceUnsupportedSqlVariantType(string underlyingType, string columnName) = The underlying type "{0}" for sql variant column "{1}" could not be resolved. + ### Save As Requests QueryServiceSaveAsResultSetNotComplete = Result cannot be saved until query execution has completed diff --git a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.xlf b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.xlf index 794925cb..6dbd66a1 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.xlf +++ b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.xlf @@ -5708,6 +5708,12 @@ . Parameters: 0 - error (String) + + The underlying type "{0}" for sql variant column "{1}" could not be resolved. + The underlying type "{0}" for sql variant column "{1}" could not be resolved. + . + Parameters: 0 - underlyingType (string), 1 - columnName (string) + \ No newline at end of file diff --git a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/DataStorage/ServiceBufferFileStreamReader.cs b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/DataStorage/ServiceBufferFileStreamReader.cs index 0c1bc040..2fea95e0 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/DataStorage/ServiceBufferFileStreamReader.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/DataStorage/ServiceBufferFileStreamReader.cs @@ -134,14 +134,15 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.DataStorage continue; } - // The typename is stored in the string - colType = Type.GetType(sqlVariantType); - - // Workaround .NET bug, see sqlbu# 440643 and vswhidbey# 599834 - // TODO: Is this workaround necessary for .NET Core? - if (colType == null && sqlVariantType == "System.Data.SqlTypes.SqlSingle") + // We need to specify the assembly name for SQL types in order to resolve the type correctly. + if (sqlVariantType.StartsWith("System.Data.SqlTypes.")) { - colType = typeof(SqlSingle); + sqlVariantType = sqlVariantType + ", System.Data.Common"; + } + colType = Type.GetType(sqlVariantType); + if (colType == null) + { + throw new ArgumentException(SR.QueryServiceUnsupportedSqlVariantType(sqlVariantType, column.ColumnName)); } } else