本文整理汇总了C#中SQLScriptList.AddRange方法的典型用法代码示例。如果您正苦于以下问题:C# SQLScriptList.AddRange方法的具体用法?C# SQLScriptList.AddRange怎么用?C# SQLScriptList.AddRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQLScriptList
的用法示例。
在下文中一共展示了SQLScriptList.AddRange方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToSqlDiff
public override SQLScriptList ToSqlDiff()
{
SQLScriptList list = new SQLScriptList();
if (this.HasState(Enums.ObjectStatusType.DropStatus))
list.Add(Drop());
if (this.HasState(Enums.ObjectStatusType.CreateStatus))
list.Add(Create());
if (this.Status == Enums.ObjectStatusType.AlterStatus)
{
list.AddRange(Rebuild());
}
list.AddRange(this.ExtendedProperties.ToSqlDiff());
return list;
}
示例2: ToSQLChangeColumns
private SQLScriptList ToSQLChangeColumns()
{
Hashtable fields = new Hashtable();
SQLScriptList list = new SQLScriptList();
if ((this.Status == Enums.ObjectStatusType.AlterStatus) || (this.Status == Enums.ObjectStatusType.RebuildStatus))
{
foreach (ObjectDependency dependency in this.Dependencys)
{
ISchemaBase itemDepens = ((Database)this.Parent).Find(dependency.Name);
if (dependency.IsCodeType)
{
list.AddRange(((ICode)itemDepens).Rebuild());
}
if (dependency.Type == Enums.ObjectType.Table)
{
Column column = ((Table)itemDepens).Columns[dependency.ColumnName];
if ((column.Parent.Status != Enums.ObjectStatusType.DropStatus) && (column.Parent.Status != Enums.ObjectStatusType.CreateStatus) && ((column.Status != Enums.ObjectStatusType.CreateStatus)))
{
if (!fields.ContainsKey(column.FullName))
{
if (column.HasToRebuildOnlyConstraint)
column.Parent.Status = Enums.ObjectStatusType.RebuildDependenciesStatus;
list.AddRange(column.RebuildConstraint(true));
list.Add("ALTER TABLE " + column.Parent.FullName + " ALTER COLUMN " + column.ToSQLRedefine(null,0, "") + "\r\nGO\r\n", 0, Enums.ScripActionType.AlterColumn);
/*Si la columna va a ser eliminada o la tabla va a ser reconstruida, no restaura la columna*/
if ((column.Status != Enums.ObjectStatusType.DropStatus) && (column.Parent.Status != Enums.ObjectStatusType.RebuildStatus))
list.AddRange(column.Alter( Enums.ScripActionType.AlterColumnRestore));
fields.Add(column.FullName, column.FullName);
}
}
}
}
}
return list;
}
示例3: ToSqlDiff
public override SQLScriptList ToSqlDiff()
{
SQLScriptList list = new SQLScriptList();
if (this.Status != Enums.ObjectStatusType.OriginalStatus)
RootParent.ActionMessage.Add(this);
if (this.HasState(Enums.ObjectStatusType.DropStatus))
list.Add(Drop());
if (this.HasState(Enums.ObjectStatusType.CreateStatus))
list.Add(Create());
if (this.HasState(Enums.ObjectStatusType.AlterStatus))
{
if (this.HasState(Enums.ObjectStatusType.RebuildDependenciesStatus))
list.AddRange(RebuildDependencys());
if (!this.GetWasInsertInDiffList(Enums.ScripActionType.DropFunction))
{
if (this.HasState(Enums.ObjectStatusType.RebuildStatus))
{
list.Add(Drop());
list.Add(Create());
}
if (this.HasState(Enums.ObjectStatusType.AlterBodyStatus))
{
int iCount = DependenciesCount;
list.Add(ToSQLAlter(), iCount, Enums.ScripActionType.AlterFunction);
}
}
}
return list;
}
示例4: ToSqlDiff
/// <summary>
/// Devuelve el schema de diferencias del Schema en formato SQL.
/// </summary>
public override SQLScriptList ToSqlDiff()
{
SQLScriptList listDiff = new SQLScriptList();
if (this.Status == Enums.ObjectStatusType.DropStatus)
{
listDiff.AddRange(ToSQLUnBindAll());
listDiff.Add(Drop());
}
if (this.Status == Enums.ObjectStatusType.CreateStatus)
listDiff.Add(Create());
if (this.Status == Enums.ObjectStatusType.AlterStatus)
{
listDiff.AddRange(ToSQLUnBindAll());
listDiff.AddRange(Rebuild());
}
return listDiff;
}
示例5: RebuildDependencys
private SQLScriptList RebuildDependencys(List<string> depends, int deepMin, int deepMax)
{
int newDeepMax = (deepMax != 0) ? deepMax + 1 : 0;
int newDeepMin = (deepMin != 0) ? deepMin - 1 : 0;
SQLScriptList list = new SQLScriptList();
for (int j = 0; j < depends.Count; j++)
{
ISchemaBase item = ((Database)Parent).Find(depends[j]);
if (item != null)
{
if ((item.Status != Enums.ObjectStatusType.CreateStatus) && (item.Status != Enums.ObjectStatusType.DropStatus))
{
if ((item.ObjectType != Enums.ObjectType.CLRStoreProcedure) && (item.ObjectType != Enums.ObjectType.Assembly) && (item.ObjectType != Enums.ObjectType.UserDataType) && (item.ObjectType != Enums.ObjectType.View) && (item.ObjectType != Enums.ObjectType.Function))
{
newDeepMin = 0;
newDeepMax = 0;
}
if (item.Status != Enums.ObjectStatusType.DropStatus)
{
if (!((item.Parent.HasState(Enums.ObjectStatusType.RebuildStatus)) && (item.ObjectType == Enums.ObjectType.Trigger)))
list.Add(item.Drop(), newDeepMin);
}
if ((this.Status != Enums.ObjectStatusType.DropStatus) && (item.Status != Enums.ObjectStatusType.CreateStatus))
list.Add(item.Create(), newDeepMax);
if (item.IsCodeType)
list.AddRange(RebuildDependencys(((ICode)item).DependenciesOut, newDeepMin, newDeepMax));
}
}
};
return list;
}
示例6: Rebuild
/// <summary>
/// Regenera el objeto, y todos sus objetos dependientes.
/// </summary>
/// <returns></returns>
public SQLScriptList Rebuild()
{
SQLScriptList list = new SQLScriptList();
list.AddRange(RebuildDependencys());
if (this.Status != Enums.ObjectStatusType.CreateStatus) list.Add(Drop(), deepMin);
if (this.Status != Enums.ObjectStatusType.DropStatus) list.Add(Create(), deepMax);
return list;
}
示例7: ToSqlDiff
public override SQLScriptList ToSqlDiff()
{
SQLScriptList list = new SQLScriptList();
if (this.Status == Enums.ObjectStatusType.DropStatus)
list.Add(Drop());
if (this.Status == Enums.ObjectStatusType.CreateStatus)
list.Add(Create());
if (this.HasState(Enums.ObjectStatusType.AlterStatus))
list.AddRange(Rebuild());
if (this.HasState(Enums.ObjectStatusType.DisabledStatus))
list.Add(this.ToSQLEnabledDisabled(), 0, Enums.ScripActionType.EnabledTrigger);
return list;
}
示例8: ToSqlDiff
public override SQLScriptList ToSqlDiff()
{
SQLScriptList list = new SQLScriptList();
if (Status != Enums.ObjectStatusType.OriginalStatus)
RootParent.ActionMessage[Parent.FullName].Add(this);
if (HasState(Enums.ObjectStatusType.DropStatus))
list.Add(Drop());
if (HasState(Enums.ObjectStatusType.CreateStatus))
list.Add(Create());
if (HasState(Enums.ObjectStatusType.AlterStatus))
{
list.Add(Drop());
list.Add(Create());
}
if (Status == Enums.ObjectStatusType.DisabledStatus)
{
list.Add(ToSqlEnabled(), Parent.DependenciesCount, Enums.ScripActionType.AlterIndex);
}
/*if (this.Status == StatusEnum.ObjectStatusType.ChangeFileGroup)
{
listDiff.Add(this.ToSQLDrop(this.FileGroup), ((Table)Parent).DependenciesCount, StatusEnum.ScripActionType.DropIndex);
listDiff.Add(this.ToSQLAdd(), ((Table)Parent).DependenciesCount, StatusEnum.ScripActionType.AddIndex);
}*/
list.AddRange(ExtendedProperties.ToSqlDiff());
return list;
}
示例9: ToSqlDiff
public override SQLScriptList ToSqlDiff(List<ISchemaBase> schemas)
{
var isAzure10 = this.Info.Version == DatabaseInfo.VersionTypeEnum.SQLServerAzure10;
var listDiff = new SQLScriptList();
listDiff.Add(new SQLScript(String.Format(@"/*
Open DBDiff {0}
http://opendbiff.codeplex.com/
Script created by {1}\{2} on {3} at {4}.
Created on: {5}
Source: {6} on {7}
Destination: {8} on {9}
*/
",
System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(),
Environment.UserDomainName,
Environment.UserName,
DateTime.Now.ToShortDateString(),
DateTime.Now.ToLongTimeString(),
Environment.MachineName,
SourceInfo != null ? SourceInfo.Database : "Uknown",
SourceInfo != null ? SourceInfo.Server : "Uknown",
Info != null ? Info.Database : "Uknown",
Info != null ? Info.Server : "Uknown",
0), 0, Enums.ScripActionType.None));
listDiff.Add(new SQLScript(String.Format(@"
SET NOEXEC OFF
SET ANSI_WARNINGS ON
SET XACT_ABORT ON
SET IMPLICIT_TRANSACTIONS OFF
SET ARITHABORT ON
SET NOCOUNT ON
SET QUOTED_IDENTIFIER ON
SET NUMERIC_ROUNDABORT OFF
SET CONCAT_NULL_YIELDS_NULL ON
SET ANSI_NULLS ON
SET ANSI_PADDING ON
GO
"), 0, Enums.ScripActionType.PreSets));
if (!isAzure10)
{
listDiff.Add("USE [" + Name + "]\r\nGO\r\n\r\n", 0, Enums.ScripActionType.UseDatabase);
listDiff.AddRange(Assemblies.ToSqlDiff(schemas));
listDiff.AddRange(UserTypes.ToSqlDiff(schemas));
listDiff.Add("BEGIN TRAN\r\nGO\r\n\r\n", 0, Enums.ScripActionType.BeginTransaction);
}
listDiff.AddRange(TablesTypes.ToSqlDiff(schemas));
listDiff.AddRange(Tables.ToSqlDiff(schemas));
listDiff.AddRange(Rules.ToSqlDiff(schemas));
listDiff.AddRange(Schemas.ToSqlDiff(schemas));
listDiff.AddRange(XmlSchemas.ToSqlDiff(schemas));
listDiff.AddRange(Procedures.ToSqlDiff(schemas));
if (!isAzure10)
{
listDiff.AddRange(CLRProcedures.ToSqlDiff(schemas));
listDiff.AddRange(CLRFunctions.ToSqlDiff(schemas));
listDiff.AddRange(FileGroups.ToSqlDiff(schemas));
}
listDiff.AddRange(DDLTriggers.ToSqlDiff(schemas));
listDiff.AddRange(Synonyms.ToSqlDiff(schemas));
listDiff.AddRange(Views.ToSqlDiff(schemas));
listDiff.AddRange(Users.ToSqlDiff(schemas));
listDiff.AddRange(Functions.ToSqlDiff(schemas));
listDiff.AddRange(Roles.ToSqlDiff(schemas));
listDiff.AddRange(PartitionFunctions.ToSqlDiff(schemas));
listDiff.AddRange(PartitionSchemes.ToSqlDiff(schemas));
if (!isAzure10)
{
listDiff.AddRange(FullText.ToSqlDiff(schemas));
listDiff.Add("IF @@TRANCOUNT>0\r\n\tCOMMIT\r\nGO\r\n\r\n", 0, Enums.ScripActionType.EndTransaction);
}
listDiff.Add("SET NOEXEC OFF\r\n", 0, Enums.ScripActionType.PostSets);
return listDiff;
}
示例10: ToSqlDiff
/// <summary>
/// Devuelve el schema de diferencias del Schema en formato SQL.
/// </summary>
public override SQLScriptList ToSqlDiff()
{
SQLScriptList list = new SQLScriptList();
if (this.Status == Enums.ObjectStatusType.DropStatus)
{
list.Add(ToSqlDrop(), 0, Enums.ScripActionType.DropXMLSchema);
}
if (this.Status == Enums.ObjectStatusType.CreateStatus)
{
list.Add(ToSql(), 0, Enums.ScripActionType.AddXMLSchema);
}
if (this.Status == Enums.ObjectStatusType.AlterStatus)
{
list.AddRange(ToSQLChangeColumns());
list.Add(ToSqlDrop() + ToSql(), 0, Enums.ScripActionType.AddXMLSchema);
}
return list;
}
示例11: ToSqlDiff
public override SQLScriptList ToSqlDiff()
{
SQLScriptList list = new SQLScriptList();
if (this.Status == Enums.ObjectStatusType.DropStatus)
{
list.AddRange(RebuildDependencys());
list.Add(Drop());
}
if (this.Status == Enums.ObjectStatusType.CreateStatus)
list.Add(Create());
if (this.HasState(Enums.ObjectStatusType.RebuildStatus))
list.AddRange(Rebuild());
if (this.HasState(Enums.ObjectStatusType.ChangeOwner))
list.Add(ToSQLAlterOwner(), 0, Enums.ScripActionType.AlterAssembly);
if (this.HasState(Enums.ObjectStatusType.PermisionSet))
list.Add(ToSQLAlter(), 0, Enums.ScripActionType.AlterAssembly);
if (this.HasState(Enums.ObjectStatusType.AlterStatus))
list.AddRange(Files.ToSqlDiff());
list.AddRange(this.ExtendedProperties.ToSqlDiff());
return list;
}
示例12: ToSqlDiff
public override SQLScriptList ToSqlDiff()
{
try
{
var list = new SQLScriptList();
if (Status == Enums.ObjectStatusType.DropStatus)
{
if (!HasAnotherUDTClass())
list.Add(Drop());
}
if (HasState(Enums.ObjectStatusType.CreateStatus))
{
list.Add(Create());
}
if (Status == Enums.ObjectStatusType.AlterStatus)
{
if (Default.Status == Enums.ObjectStatusType.CreateStatus)
list.Add(Default.ToSQLAddBind(), 0, Enums.ScripActionType.AddUserDataType);
if (Default.Status == Enums.ObjectStatusType.DropStatus)
list.Add(Default.ToSQLAddUnBind(), 0, Enums.ScripActionType.UnbindRuleType);
if (Rule.Status == Enums.ObjectStatusType.CreateStatus)
list.Add(Rule.ToSQLAddBind(), 0, Enums.ScripActionType.AddUserDataType);
if (Rule.Status == Enums.ObjectStatusType.DropStatus)
list.Add(Rule.ToSQLAddUnBind(), 0, Enums.ScripActionType.UnbindRuleType);
}
if (Status == Enums.ObjectStatusType.RebuildStatus)
{
list.AddRange(ToSQLChangeColumns());
if (!GetWasInsertInDiffList(Enums.ScripActionType.DropUserDataType))
{
list.Add(ToSqlDrop() + ToSql(), 0, Enums.ScripActionType.AddUserDataType);
}
else
list.Add(Create());
}
if (HasState(Enums.ObjectStatusType.DropOlderStatus))
{
list.Add(SQLDropOlder(), 0, Enums.ScripActionType.AddUserDataType);
}
return list;
}
catch (Exception ex)
{
return null;
}
}
示例13: ToSQLChangeColumns
private SQLScriptList ToSQLChangeColumns()
{
var fields = new Hashtable();
var list = new SQLScriptList();
var listDependencys = new SQLScriptList();
if ((Status == Enums.ObjectStatusType.AlterStatus) || (Status == Enums.ObjectStatusType.RebuildStatus))
{
foreach (ObjectDependency dependency in Dependencys)
{
ISchemaBase itemDepens = ((Database) Parent).Find(dependency.Name);
/*Si la dependencia es una funcion o una vista, reconstruye el objecto*/
if (dependency.IsCodeType)
{
if (itemDepens != null)
list.AddRange(((ICode) itemDepens).Rebuild());
}
/*Si la dependencia es una tabla, reconstruye los indices, constraint y columnas asociadas*/
if (dependency.Type == Enums.ObjectType.Table)
{
Column column = ((Table) itemDepens).Columns[dependency.ColumnName];
if ((column.Parent.Status != Enums.ObjectStatusType.DropStatus) &&
(column.Parent.Status != Enums.ObjectStatusType.CreateStatus) &&
((column.Status != Enums.ObjectStatusType.CreateStatus) || (column.IsComputed)))
{
if (!fields.ContainsKey(column.FullName))
{
listDependencys.AddRange(RebuildDependencys((Table) itemDepens));
if (column.HasToRebuildOnlyConstraint)
//column.Parent.Status = Enums.ObjectStatusType.AlterRebuildDependenciesStatus;
list.AddRange(column.RebuildDependencies());
if (!column.IsComputed)
{
list.AddRange(column.RebuildConstraint(true));
list.Add(
"ALTER TABLE " + column.Parent.FullName + " ALTER COLUMN " +
column.ToSQLRedefine(Type, Size, null) + "\r\nGO\r\n", 0,
Enums.ScripActionType.AlterColumn);
/*Si la columna va a ser eliminada o la tabla va a ser reconstruida, no restaura la columna*/
if ((column.Status != Enums.ObjectStatusType.DropStatus) &&
(column.Parent.Status != Enums.ObjectStatusType.RebuildStatus))
list.AddRange(column.Alter(Enums.ScripActionType.AlterColumnRestore));
}
else
{
if (column.Status != Enums.ObjectStatusType.CreateStatus)
{
if (!column.GetWasInsertInDiffList(Enums.ScripActionType.AlterColumnFormula))
{
column.SetWasInsertInDiffList(Enums.ScripActionType.AlterColumnFormula);
list.Add(column.ToSqlDrop(), 0, Enums.ScripActionType.AlterColumnFormula);
List<ISchemaBase> drops =
((Database) column.Parent.Parent).Dependencies.Find(column.Parent.Id,
column.Id, 0);
drops.ForEach(item =>
{
if (item.Status != Enums.ObjectStatusType.CreateStatus)
list.Add(item.Drop());
if (item.Status != Enums.ObjectStatusType.DropStatus)
list.Add(item.Create());
});
/*Si la columna va a ser eliminada o la tabla va a ser reconstruida, no restaura la columna*/
if ((column.Status != Enums.ObjectStatusType.DropStatus) &&
(column.Parent.Status != Enums.ObjectStatusType.RebuildStatus))
list.Add(column.ToSqlAdd(), 0,
Enums.ScripActionType.AlterColumnFormulaRestore);
}
}
}
fields.Add(column.FullName, column.FullName);
}
}
}
}
}
list.AddRange(listDependencys);
return list;
}
示例14: RebuildDependencys
private SQLScriptList RebuildDependencys(Table table)
{
var list = new SQLScriptList();
List<ISchemaBase> items = ((Database) table.Parent).Dependencies.Find(table.Id);
items.ForEach(item =>
{
ISchemaBase realItem = ((Database) table.Parent).Find(item.FullName);
if (realItem.IsCodeType)
list.AddRange(((ICode) realItem).Rebuild());
});
return list;
}
示例15: ToSqlDiff
/*public List<ISchemaBase> FindAllByColumn(String ColumnName)
{
this.t
}*/
public override SQLScriptList ToSqlDiff()
{
var listDiff = new SQLScriptList();
listDiff.Add("USE [" + Name + "]\r\nGO\r\n\r\n", 0, Enums.ScripActionType.UseDatabase);
listDiff.AddRange(Assemblies.ToSqlDiff());
listDiff.AddRange(Defaults.ToSqlDiff());
listDiff.AddRange(UserTypes.ToSqlDiff());
listDiff.AddRange(TablesTypes.ToSqlDiff());
listDiff.AddRange(Tables.ToSqlDiff());
listDiff.AddRange(Rules.ToSqlDiff());
listDiff.AddRange(Schemas.ToSqlDiff());
listDiff.AddRange(XmlSchemas.ToSqlDiff());
listDiff.AddRange(Procedures.ToSqlDiff());
listDiff.AddRange(CLRProcedures.ToSqlDiff());
listDiff.AddRange(CLRFunctions.ToSqlDiff());
listDiff.AddRange(FileGroups.ToSqlDiff());
listDiff.AddRange(DDLTriggers.ToSqlDiff());
listDiff.AddRange(Synonyms.ToSqlDiff());
listDiff.AddRange(Views.ToSqlDiff());
listDiff.AddRange(Users.ToSqlDiff());
listDiff.AddRange(Functions.ToSqlDiff());
listDiff.AddRange(Roles.ToSqlDiff());
listDiff.AddRange(PartitionFunctions.ToSqlDiff());
listDiff.AddRange(PartitionSchemes.ToSqlDiff());
listDiff.AddRange(FullText.ToSqlDiff());
return listDiff;
}