diff --git a/src/Microsoft.SqlTools.ServiceLayer/TableDesigner/Contracts/Requests/GeneratePreviewReportRequest.cs b/src/Microsoft.SqlTools.ServiceLayer/TableDesigner/Contracts/Requests/GeneratePreviewReportRequest.cs index b65a876b..c2bcd866 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/TableDesigner/Contracts/Requests/GeneratePreviewReportRequest.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/TableDesigner/Contracts/Requests/GeneratePreviewReportRequest.cs @@ -3,6 +3,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. // +using System.Collections.Generic; using Microsoft.SqlTools.Hosting.Protocol.Contracts; namespace Microsoft.SqlTools.ServiceLayer.TableDesigner.Contracts @@ -22,6 +23,11 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner.Contracts /// format (mimetype) of the string /// public string MimeType; + + /// + /// Metadata about the table + /// + public Dictionary Metadata { get; set; } } /// diff --git a/src/Microsoft.SqlTools.ServiceLayer/TableDesigner/Contracts/Requests/ProcessTableDesignerEditRequest.cs b/src/Microsoft.SqlTools.ServiceLayer/TableDesigner/Contracts/Requests/ProcessTableDesignerEditRequest.cs index c978e52d..c523f91f 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/TableDesigner/Contracts/Requests/ProcessTableDesignerEditRequest.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/TableDesigner/Contracts/Requests/ProcessTableDesignerEditRequest.cs @@ -3,6 +3,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. // +using System.Collections.Generic; using Microsoft.SqlTools.Hosting.Protocol.Contracts; using Microsoft.SqlTools.Utility; @@ -24,6 +25,8 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner.Contracts public bool IsValid { get; set; } public TableDesignerIssue[] Issues { get; set; } + + public Dictionary Metadata { get; set; } } /// diff --git a/src/Microsoft.SqlTools.ServiceLayer/TableDesigner/Contracts/Requests/PublishTableChangesRequest.cs b/src/Microsoft.SqlTools.ServiceLayer/TableDesigner/Contracts/Requests/PublishTableChangesRequest.cs index 4489d758..dfc7cdf7 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/TableDesigner/Contracts/Requests/PublishTableChangesRequest.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/TableDesigner/Contracts/Requests/PublishTableChangesRequest.cs @@ -3,6 +3,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. // +using System.Collections.Generic; using Microsoft.SqlTools.Hosting.Protocol.Contracts; namespace Microsoft.SqlTools.ServiceLayer.TableDesigner.Contracts @@ -12,6 +13,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner.Contracts public TableInfo NewTableInfo; public TableViewModel ViewModel; public TableDesignerView View; + public Dictionary Metadata; } /// diff --git a/src/Microsoft.SqlTools.ServiceLayer/TableDesigner/TableDesignerMetadata.cs b/src/Microsoft.SqlTools.ServiceLayer/TableDesigner/TableDesignerMetadata.cs new file mode 100644 index 00000000..77c20132 --- /dev/null +++ b/src/Microsoft.SqlTools.ServiceLayer/TableDesigner/TableDesignerMetadata.cs @@ -0,0 +1,28 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using Dac = Microsoft.Data.Tools.Sql.DesignServices.TableDesigner; + +namespace Microsoft.SqlTools.ServiceLayer.TableDesigner +{ + public static class TableDesignerMetadata + { + public static bool IsNode(this Dac.TableDesigner tableDesigner) + { + return tableDesigner.TableViewModel.IsNode; + } + + public static bool IsEdge(this Dac.TableDesigner tableDesigner) + { + return tableDesigner.TableViewModel.IsEdge; + } + + public static bool IsSystemVersioned(this Dac.TableDesigner tableDesigner) + { + return tableDesigner.TableViewModel.IsSystemVersioningEnabled; + } + } + +} \ No newline at end of file diff --git a/src/Microsoft.SqlTools.ServiceLayer/TableDesigner/TableDesignerService.cs b/src/Microsoft.SqlTools.ServiceLayer/TableDesigner/TableDesignerService.cs index 585c130c..6f2d170b 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/TableDesigner/TableDesignerService.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/TableDesigner/TableDesignerService.cs @@ -119,7 +119,8 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner ViewModel = this.GetTableViewModel(requestParams.TableInfo), IsValid = issues.Where(i => i.Severity == IssueSeverity.Error).Count() == 0, Issues = issues.ToArray(), - View = refreshViewRequired ? this.GetDesignerViewInfo(requestParams.TableInfo) : null + View = refreshViewRequired ? this.GetDesignerViewInfo(requestParams.TableInfo) : null, + Metadata = this.GetMetadata(requestParams.TableInfo) }); }); } @@ -147,7 +148,8 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner { NewTableInfo = tableInfo, ViewModel = this.GetTableViewModel(tableInfo), - View = GetDesignerViewInfo(tableInfo) + View = GetDesignerViewInfo(tableInfo), + Metadata = this.GetMetadata(tableInfo) }); }); } @@ -171,6 +173,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner var generatePreviewReportResult = new GeneratePreviewReportResult(); generatePreviewReportResult.Report = report; generatePreviewReportResult.MimeType = "text/markdown"; + generatePreviewReportResult.Metadata = this.GetMetadata(tableInfo); await requestContext.SendResult(generatePreviewReportResult); }); } @@ -1298,9 +1301,9 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner private Dac.TableDesigner CreateTableDesigner(TableInfo tableInfo) { - var connectinStringbuilder = new SqlConnectionStringBuilder(tableInfo.ConnectionString); - connectinStringbuilder.InitialCatalog = tableInfo.Database; - var connectionString = connectinStringbuilder.ToString(); + var connectionStringbuilder = new SqlConnectionStringBuilder(tableInfo.ConnectionString); + connectionStringbuilder.InitialCatalog = tableInfo.Database; + var connectionString = connectionStringbuilder.ToString(); var tableDesigner = new Dac.TableDesigner(connectionString, tableInfo.AccessToken, tableInfo.Schema, tableInfo.Name, tableInfo.IsNewTable); this.idTableMap[tableInfo.Id] = tableDesigner; return tableDesigner; @@ -1319,6 +1322,18 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner } } + private Dictionary GetMetadata(TableInfo tableInfo) + { + var tableDesigner = this.GetTableDesigner(tableInfo); + var metadata = new Dictionary() + { + { "IsEdge", tableDesigner.IsEdge().ToString() }, + { "IsNode", tableDesigner.IsNode().ToString() }, + { "IsSystemVersioned", tableDesigner.IsSystemVersioned().ToString() } + }; + return metadata; + } + /// /// Disposes the table designer Service ///