new table designer features (#1420)

* support graph table types

* more fixes

* refresh view upon edit

* support temporal tables

* temporal and memory table

* primary key and default constraint

* bug fixes

* dispose table designer

* vbump dacfx

* update string
This commit is contained in:
Alan Ren
2022-03-08 18:52:51 -08:00
committed by GitHub
parent 3e5bf00cc5
commit 7a326b2487
17 changed files with 1896 additions and 89 deletions

View File

@@ -0,0 +1,93 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System;
using System.Linq;
using System.Collections.Generic;
using Microsoft.Data.Tools.Sql.DesignServices.TableDesigner;
namespace Microsoft.SqlTools.ServiceLayer.TableDesigner
{
public abstract class EnumUtil<T> where T : struct, IConvertible
{
protected Dictionary<string, T> Mapping = new Dictionary<string, T>();
public List<string> DisplayNames
{
get
{
return this.Mapping.Keys.ToList();
}
}
public string GetName(T enumValue)
{
foreach (var key in this.Mapping.Keys)
{
if (this.Mapping[key].Equals(enumValue))
{
return key;
}
}
throw new KeyNotFoundException(SR.UnknownEnumString(enumValue.ToString()));
}
public T GetValue(string displayName)
{
if (this.Mapping.ContainsKey(displayName))
{
return this.Mapping[displayName];
}
else
{
throw new KeyNotFoundException(SR.UnknownEnumString(displayName));
}
}
}
public class SqlForeignKeyActionUtil : EnumUtil<SqlForeignKeyAction>
{
public static SqlForeignKeyActionUtil Instance { get; } = new SqlForeignKeyActionUtil();
public SqlForeignKeyActionUtil()
{
this.Mapping.Add(SR.SqlForeignKeyAction_NoAction, SqlForeignKeyAction.NoAction);
this.Mapping.Add(SR.SqlForeignKeyAction_Cascade, SqlForeignKeyAction.Cascade);
this.Mapping.Add(SR.SqlForeignKeyAction_SetNull, SqlForeignKeyAction.SetNull);
this.Mapping.Add(SR.SqlForeignKeyAction_SetDefault, SqlForeignKeyAction.SetDefault);
}
public List<string> EdgeConstraintOnDeleteActionNames
{
get
{
return new List<string> { SR.SqlForeignKeyAction_NoAction, SR.SqlForeignKeyAction_Cascade };
}
}
}
public class SqlTableDurabilityUtil : EnumUtil<TableDurability>
{
public static SqlTableDurabilityUtil Instance { get; } = new SqlTableDurabilityUtil();
public SqlTableDurabilityUtil()
{
this.Mapping.Add(SR.SqlTableDurability_SchemaAndData, TableDurability.SchemaAndData);
this.Mapping.Add(SR.SqlTableDurability_SchemaOnly, TableDurability.SchemaOnly);
}
}
public class ColumnGeneratedAlwaysAsTypeUtil : EnumUtil<ColumnGeneratedAlwaysAsType>
{
public static ColumnGeneratedAlwaysAsTypeUtil Instance { get; } = new ColumnGeneratedAlwaysAsTypeUtil();
public ColumnGeneratedAlwaysAsTypeUtil()
{
this.Mapping.Add(SR.GeneratedAlwaysColumnType_None, ColumnGeneratedAlwaysAsType.None);
this.Mapping.Add(SR.GeneratedAlwaysColumnType_RowStart, ColumnGeneratedAlwaysAsType.GeneratedAlwaysAsRowStart);
this.Mapping.Add(SR.GeneratedAlwaysColumnType_RowEnd, ColumnGeneratedAlwaysAsType.GeneratedAlwaysAsRowEnd);
}
}
}