diff --git a/src/Microsoft.SqlTools.ServiceLayer/TableDesigner/TableDesignerService.cs b/src/Microsoft.SqlTools.ServiceLayer/TableDesigner/TableDesignerService.cs index 217b655608..88ff72188c 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/TableDesigner/TableDesignerService.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/TableDesigner/TableDesignerService.cs @@ -108,8 +108,10 @@ private Task HandleProcessTableDesignerEditRequest(ProcessTableDesignerEditReque case DesignerEditType.Remove: this.HandleRemoveItemRequest(requestParams); break; + case DesignerEditType.Update: + this.HandleUpdateItemRequest(requestParams); + break; default: - // TODO: Handle 'Update' request break; } await requestContext.SendResult(new ProcessTableDesignerEditResponse() @@ -185,6 +187,49 @@ private void HandleRemoveItemRequest(ProcessTableDesignerEditRequestParams reque } } + private void HandleUpdateItemRequest(ProcessTableDesignerEditRequestParams requestParams) + { + var table = this.GetTable(requestParams.TableInfo); + var path = requestParams.TableChangeInfo.Path; + + if (path.Length == 3) + { + var propertyName = path[0] as string; + switch (propertyName) + { + case TablePropertyNames.Columns: + var colIndex = Convert.ToInt32(path[1]); + var colPropertyName = path[2] as string; + switch (colPropertyName) + { + case TableColumnPropertyNames.Name: + table.Columns.Items[colIndex].Name = requestParams.TableChangeInfo.Value as string; + break; + case TableColumnPropertyNames.Length: + table.Columns.Items[colIndex].Length = requestParams.TableChangeInfo.Value as string; + break; + case TableColumnPropertyNames.AllowNulls: + table.Columns.Items[colIndex].IsNullable = (bool)requestParams.TableChangeInfo.Value; + break; + case TableColumnPropertyNames.Precision: + table.Columns.Items[colIndex].Precision = Int32.Parse(requestParams.TableChangeInfo.Value as string); + break; + case TableColumnPropertyNames.Scale: + table.Columns.Items[colIndex].Scale = Int32.Parse(requestParams.TableChangeInfo.Value as string); + break; + case TableColumnPropertyNames.Type: + table.Columns.Items[colIndex].DataType = requestParams.TableChangeInfo.Value as string; + break; + default: + break; + } + break; + default: + break; + } + } + } + private TableViewModel GetTableViewModel(TableInfo tableInfo) { var table = this.GetTable(tableInfo);