Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ExcludeIndexes work with VS extension #2649

Merged
merged 1 commit into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.ObjectModel;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using RevEng.Common;

namespace EFCorePowerTools.Contracts.ViewModels
Expand All @@ -9,6 +10,8 @@ public interface ITableInformationViewModel : IObjectTreeEditableViewModel, IObj

bool HasPrimaryKey { get; }

IEnumerable<string> ExcludedIndexes { get; set; }

ObjectType ObjectType { get; set; }

ObjectTypeIcon ObjectTypeIcon { get; }
Expand All @@ -19,4 +22,4 @@ public interface ITableInformationViewModel : IObjectTreeEditableViewModel, IObj

string ModelDisplayName { get; set; }
}
}
}
3 changes: 2 additions & 1 deletion src/GUI/Shared/ViewModels/ObjectTreeViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public IEnumerable<SerializationTableModel> GetSelectedObjects()
{
return Objects
.Where(c => c.IsSelected.Value)
.Select(m => new SerializationTableModel(m.ModelDisplayName, m.ObjectType, m.Columns.Where(c => !c.IsSelected.Value).Select(c => c.Name).ToList(), null));
.Select(m => new SerializationTableModel(m.ModelDisplayName, m.ObjectType, m.Columns.Where(c => !c.IsSelected.Value).Select(c => c.Name).ToList(), m.ExcludedIndexes?.ToList() ?? null));
}

public IEnumerable<Schema> GetRenamedObjects()
Expand Down Expand Up @@ -254,6 +254,7 @@ public void SelectObjects(IEnumerable<SerializationTableModel> objects)
foreach (var obj in Objects)
{
var t = objects.FirstOrDefault(m => m.Name == obj.ModelDisplayName);
obj.ExcludedIndexes = t?.ExcludedIndexes ?? null;
obj.SetSelectedCommand.Execute(t != null);
if (obj.ObjectType.HasColumns() && obj.IsSelected.Value)
{
Expand Down
9 changes: 6 additions & 3 deletions src/GUI/Shared/ViewModels/PickTablesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,12 @@ private void Ok_Executed()
/// At least a single table, function or stored procedure must be selected.
/// </summary>
private bool Ok_CanExecute()
=> ObjectTree.GetSelectedObjects().Any(c => c.ObjectType.HasColumns())
|| ObjectTree.GetSelectedObjects().Any(c => c.ObjectType == ObjectType.Procedure)
|| ObjectTree.GetSelectedObjects().Any(c => c.ObjectType == ObjectType.ScalarFunction);
{
var selectedObjects = ObjectTree.GetSelectedObjects().ToList();
return selectedObjects.Exists(c => c.ObjectType.HasColumns())
|| selectedObjects.Exists(c => c.ObjectType == ObjectType.Procedure)
|| selectedObjects.Exists(c => c.ObjectType == ObjectType.ScalarFunction);
}

private void Cancel_Executed()
{
Expand Down
3 changes: 3 additions & 0 deletions src/GUI/Shared/ViewModels/TableInformationViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Linq;
Expand Down Expand Up @@ -37,6 +38,8 @@ public TableInformationViewModel(IMessenger messenger)
Columns.CollectionChanged += Columns_CollectionChanged;
}

public IEnumerable<string> ExcludedIndexes { get; set; }

public string Schema
{
get => schema;
Expand Down
5 changes: 4 additions & 1 deletion test/ScaffoldingTester/ScaffoldingTester/efpt.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
"T4TemplatePath": null,
"Tables": [
{
"ExcludedIndexes": [
"PK_Categories"
],
"Name": "[dbo].[Categories]",
"ObjectType": 0
},
Expand Down Expand Up @@ -164,6 +167,7 @@
"UseAsyncStoredProcedureCalls": true,
"UseBoolPropertiesWithoutDefaultSql": true,
"UseDatabaseNames": false,
"UseDatabaseNamesForRoutines": false,
"UseDateOnlyTimeOnly": false,
"UseDbContextSplitting": false,
"UseDecimalDataAnnotationForSprocResult": true,
Expand All @@ -178,7 +182,6 @@
"UseNoObjectFilter": false,
"UseNodaTime": false,
"UseNullableReferences": false,
"UsePascalNamesForStoredProceduresAndFunctions": false,
"UsePrefixNavigationNaming": false,
"UseSchemaFolders": false,
"UseSchemaNamespaces": false,
Expand Down