mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-15 02:48:35 -05:00
add foreign keys and constraints (#1316)
* add foreign keys and constraints * add property name
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.TableDesigner.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// The view model of check constraint
|
||||
/// </summary>
|
||||
public class CheckConstraintViewModel : ObjectViewModelBase
|
||||
{
|
||||
public InputBoxProperties Expression { get; set; } = new InputBoxProperties();
|
||||
public CheckBoxProperties Enabled { get; set; } = new CheckBoxProperties();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.TableDesigner.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// The view model of foreign key.
|
||||
/// </summary>
|
||||
public class ForeignKeyViewModel : ObjectViewModelBase
|
||||
{
|
||||
public CheckBoxProperties Enabled { get; set; } = new CheckBoxProperties();
|
||||
|
||||
public DropdownProperties OnDeleteAction { get; set; } = new DropdownProperties();
|
||||
|
||||
public DropdownProperties OnUpdateAction { get; set; } = new DropdownProperties();
|
||||
|
||||
public DropdownProperties PrimaryKeyTable { get; set; } = new DropdownProperties();
|
||||
|
||||
public CheckBoxProperties IsNotForReplication { get; set; } = new CheckBoxProperties();
|
||||
|
||||
public TableComponentProperties<ForeignKeyColumnMapping> Columns { get; set; } = new TableComponentProperties<ForeignKeyColumnMapping>();
|
||||
}
|
||||
|
||||
public class ForeignKeyColumnMapping
|
||||
{
|
||||
public DropdownProperties PrimaryKeyColumn { get; set; } = new DropdownProperties();
|
||||
|
||||
public DropdownProperties ForeignKeyColumn { get; set; } = new DropdownProperties();
|
||||
}
|
||||
}
|
||||
@@ -16,22 +16,12 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner.Contracts
|
||||
|
||||
public InputBoxProperties Description { get; set; } = new InputBoxProperties();
|
||||
|
||||
public TableColumnCollection Columns { get; set; } = new TableColumnCollection();
|
||||
public TableComponentProperties<TableColumnViewModel> Columns { get; set; } = new TableComponentProperties<TableColumnViewModel>();
|
||||
|
||||
public TableComponentProperties<ForeignKeyViewModel> ForeignKeys { get; set; } = new TableComponentProperties<ForeignKeyViewModel>();
|
||||
|
||||
public TableComponentProperties<CheckConstraintViewModel> CheckConstraints { get; set; } = new TableComponentProperties<CheckConstraintViewModel>();
|
||||
|
||||
public InputBoxProperties Script { get; set; } = new InputBoxProperties();
|
||||
}
|
||||
|
||||
public class TableColumnCollection : TableComponentProperties<TableColumnViewModel>
|
||||
{
|
||||
[JsonIgnore]
|
||||
protected override string NewObjectNamePrefix { get { return "column"; } }
|
||||
|
||||
protected override TableColumnViewModel CreateNew(string name)
|
||||
{
|
||||
//TODO: Add the default values
|
||||
var column = new TableColumnViewModel();
|
||||
column.Name.Value = this.GetDefaultNewObjectName();
|
||||
return column;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user