-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor update schema manager. Add order by db object
- Loading branch information
1 parent
97d3765
commit 8ae1f67
Showing
20 changed files
with
267 additions
and
320 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ public enum Operation | |
Alter, | ||
Drop, | ||
Enabled, | ||
Disabled, | ||
Add | ||
Disabled | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,29 @@ | ||
using SqlSchemaCompare.Core.DbStructures; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Linq; | ||
|
||
namespace SqlSchemaCompare.Core.TSql | ||
{ | ||
public class TSqlResultProcessDbObject | ||
{ | ||
|
||
public StringBuilder UpdateSchemaStringBuild { get; set; } = new(); | ||
public List<DbObject> ToDrop { get; private set; } = new(); | ||
public List<DbObject> ToAlter { get; private set; } = new(); | ||
public List<DbObject> ToCreate { get; private set; } = new(); | ||
public List<DbObject> ToEnable { get; private set; } = new(); | ||
public List<DbObject> ToDisable { get; private set; } = new(); | ||
|
||
public void AddToAlter<T>(IList<T> dbObjects) where T: DbObject | ||
{ | ||
ToAlter.AddRange(dbObjects); | ||
} | ||
public void AddToCreate<T>(IList<T> dbObjects) where T : DbObject | ||
{ | ||
ToCreate.AddRange(dbObjects); | ||
} | ||
public void AddToDrop<T>(IList<T> dbObjects) where T : DbObject | ||
public class OperationOnDbObject | ||
{ | ||
ToDrop.AddRange(dbObjects); | ||
public DbObject DbObject { get; init; } | ||
public Operation Operation { get; init; } | ||
} | ||
|
||
public void AddToAlter<T>(T dbObjects) where T : DbObject | ||
{ | ||
ToAlter.Add(dbObjects); | ||
} | ||
public void AddToCreate<T>(T dbObjects) where T : DbObject | ||
public List<OperationOnDbObject> OperationsOnDbObject { get; private set; } = new(); | ||
public void AddOperation<T>(DbObject dbObjects, Operation operation) where T : DbObject | ||
{ | ||
ToCreate.Add(dbObjects); | ||
OperationsOnDbObject.Add(new OperationOnDbObject { DbObject = dbObjects, Operation = operation } ); | ||
} | ||
public void AddToDrop<T>(T dbObjects) where T : DbObject | ||
public void AddOperation<T>(IList<T> dbObjects, Operation operation) where T : DbObject | ||
{ | ||
ToDrop.Add(dbObjects); | ||
} | ||
public void AddToEnable<T>(T dbObjects) where T : DbObject | ||
{ | ||
ToEnable.Add(dbObjects); | ||
} | ||
public void AddToDisable<T>(T dbObjects) where T : DbObject | ||
dbObjects.ToList().ForEach(x => AddOperation<T>(x, operation)); | ||
} | ||
|
||
public IEnumerable<DbObject> GetDbObject(DbObjectType dbObjectType, Operation operation) | ||
{ | ||
ToDisable.Add(dbObjects); | ||
return OperationsOnDbObject.Where(x => x.DbObject.DbObjectType == dbObjectType && x.Operation == operation).Select(x => x.DbObject); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.